From: James Sedgwick <jsedgwick@fb.com>
Date: Thu, 14 May 2015 00:37:50 +0000 (-0700)
Subject: more restrictive implicit Future construction enabling
X-Git-Tag: v0.39.0~17
X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=f639b4542e084dd4cd5130000b63384a53f50973;p=folly.git

more restrictive implicit Future construction enabling

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
---

diff --git a/folly/futures/Future-inl.h b/folly/futures/Future-inl.h
index 62f48007..003c9c89 100644
--- a/folly/futures/Future-inl.h
+++ b/folly/futures/Future-inl.h
@@ -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));
diff --git a/folly/futures/Future.h b/folly/futures/Future.h
index b26369ce..d0824aa8 100644
--- a/folly/futures/Future.h
+++ b/folly/futures/Future.h
@@ -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<