Add folly::Try<T>::emplace(), emplaceException() and tryEmplace()
Summary: Add some methods to `folly::Try<T>` to allow the user to in-place construct a value or exception_wrapper inside the Try object at some point after the Try object was constructed. Previously, you had to construct a new temporary `Try<T>` object from the value and move-assign the value. The difference between `t.emplace(args...)` and `tryEmplace(t, args...)` is that the latter catches any exceptions thrown by the constructor and stores the exception in the Try object whereas the former lets the exception propagate out to the caller and leaves the Try object in an empty state. The `Try<void>` implementation now only conditionally constructs the contained exception_wrapper only if hasValue_ is false. This was needed to be able to have the `.emplaceException()` method correctly in-place construct the `exception_wrapper` object. Reviewed By: yfeldblum Differential Revision: D9352439 fbshipit-source-id: f34a4479acb2f93aed11f9626b3152511386bfea
Showing
Please register or sign in to comment