Cleanup Future(Value) ctor
authorHans Fugal <fugalh@fb.com>
Wed, 22 Apr 2015 23:32:22 +0000 (16:32 -0700)
committerAlecs King <int@fb.com>
Mon, 27 Apr 2015 23:51:58 +0000 (16:51 -0700)
Summary:
We don't need to check for void after all, and with perfect forwarding we don't need separate const& and && versions.

Test Plan: tests still pass

Reviewed By: jsedgwick@fb.com

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

FB internal diff: D2014264

Tasks: 6847876

Signature: t1:2014264:1429735036:01ac166399ef8d0f2f34adb51e965809022c2b64

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

index a4ec35f09284624737b0640ca2a29f1f8c92ed5c..5604ed06e953925c5d8233764fc4ec9f0cadcb61 100644 (file)
@@ -44,22 +44,10 @@ Future<T>& Future<T>::operator=(Future<T>&& other) noexcept {
 }
 
 template <class T>
-template <class F>
-Future<T>::Future(
-  const typename std::enable_if<!std::is_void<F>::value, F>::type& val)
-    : core_(nullptr) {
-  Promise<F> p;
-  p.setValue(val);
-  *this = p.getFuture();
-}
-
-template <class T>
-template <class F>
-Future<T>::Future(
-  typename std::enable_if<!std::is_void<F>::value, F>::type&& val)
-    : core_(nullptr) {
-  Promise<F> p;
-  p.setValue(std::forward<F>(val));
+template <class T2>
+Future<T>::Future(T2&& val) : core_(nullptr) {
+  Promise<T> p;
+  p.setValue(std::forward<T2>(val));
   *this = p.getFuture();
 }
 
index a14d62cfd89cb788be10fb1d889c00dc9cbae64c..8e2b3f1ee4d024c924fcc63b8fd055e8ba695a56 100644 (file)
@@ -213,14 +213,9 @@ class Future {
   Future(Future&&) noexcept;
   Future& operator=(Future&&) noexcept;
 
-  // makeFuture
-  template <class F = T>
-  /* implicit */
-  Future(const typename std::enable_if<!std::is_void<F>::value, F>::type& val);
-
-  template <class F = T>
+  /// Construct a Future from a value (perfect forwarding)
   /* implicit */
-  Future(typename std::enable_if<!std::is_void<F>::value, F>::type&& val);
+  template <class T2 = T> Future(T2&& val);
 
   template <class F = T,
             typename std::enable_if<std::is_void<F>::value, int>::type = 0>