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
}
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();
}
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>