Nuke Future<void> (folly/futures)
[folly.git] / folly / futures / Try.h
index 5f5f634b2d984e515f00237e0ab0a7e260edac81..d06d5b6225b73e74e696aad711c3614cdf17a4d1 100644 (file)
@@ -35,8 +35,7 @@ namespace folly {
  * context. Exceptions are stored as exception_wrappers so that the user can
  * minimize rethrows if so desired.
  *
- * There is a specialization, Try<void>, which represents either success
- * or an exception.
+ * To represent success or a captured exception, use Try<Unit>
  */
 template <class T>
 class Try {
@@ -74,6 +73,12 @@ class Try {
    */
   explicit Try(T&& v) : contains_(Contains::VALUE), value_(std::move(v)) {}
 
+  /// Implicit conversion from Try<void> to Try<Unit>
+  template <class T2 = T>
+  /* implicit */
+  Try(typename std::enable_if<std::is_same<Unit, T2>::value,
+                              Try<void> const&>::type t);
+
   /*
    * Construct a Try with an exception_wrapper
    *
@@ -364,7 +369,7 @@ typename std::enable_if<
 makeTryWith(F&& f);
 
 /*
- * Specialization of makeTryWith for void
+ * Specialization of makeTryWith for void return
  *
  * @param f a function to execute and capture the result of
  *