Cleanup Future(Value) ctor

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
This commit is contained in:
Hans Fugal
2015-04-22 16:32:22 -07:00
committed by Alecs King
parent 03b14b9cb0
commit 2aed11df40
2 changed files with 6 additions and 23 deletions
+4 -16
View 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();
}
+2 -7
View File
@@ -213,14 +213,9 @@ class Future {
Future(Future&&) noexcept;
Future& operator=(Future&&) noexcept;
// makeFuture
template <class F = T>
/// Construct a Future from a value (perfect forwarding)
/* implicit */
Future(const typename std::enable_if<!std::is_void<F>::value, F>::type& val);
template <class F = T>
/* 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>