more restrictive implicit Future construction enabling
authorJames Sedgwick <jsedgwick@fb.com>
Thu, 14 May 2015 00:37:50 +0000 (17:37 -0700)
committerViswanath Sivakumar <viswanath@fb.com>
Wed, 20 May 2015 17:57:04 +0000 (10:57 -0700)
Summary:
Decay so we don't try to instantiate this for attempts to copy Futures
See https://www.facebook.com/groups/499316706783616/permalink/863260220389261/

Test Plan: unit

Reviewed By: hans@fb.com

Subscribers: hannesr, folly-diffs@, jsedgwick, yfeldblum, chalfant

FB internal diff: D2062442

Signature: t1:2062442:1431551169:d1ba61537c998067ee7e6f4819f7e0817cc2e700

folly/futures/Future-inl.h
folly/futures/Future.h

index 62f480072e68fae901219dc54b96c40b064b28d7..003c9c896b62955a8c45bb7eff8b25ad8ee842a2 100644 (file)
@@ -44,8 +44,7 @@ Future<T>& Future<T>::operator=(Future<T>&& other) noexcept {
 }
 
 template <class T>
-template <class T2,
-          typename std::enable_if<!isFuture<T2>::value, void*>::type>
+template <class T2, typename>
 Future<T>::Future(T2&& val) : core_(nullptr) {
   Promise<T> p;
   p.setValue(std::forward<T2>(val));
index b26369cee455bc561217e7484d1049fa436c82d4..d0824aa8a7b35b01cc88f1772efa05f19685d811 100644 (file)
@@ -55,10 +55,10 @@ class Future {
   Future& operator=(Future&&) noexcept;
 
   /// Construct a Future from a value (perfect forwarding)
-  /* implicit */
-  template <class T2 = T,
-            typename std::enable_if<!isFuture<T2>::value, void*>::type = nullptr>
-  Future(T2&& val);
+  template <class T2 = T, typename =
+            typename std::enable_if<
+              !isFuture<typename std::decay<T2>::type>::value>::type>
+  /* implicit */ Future(T2&& val);
 
   template <class T2 = T,
             typename std::enable_if<