Commit 2aed11df authored by Hans Fugal's avatar Hans Fugal Committed by Alecs King

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
parent 03b14b9c
......@@ -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();
}
......
......@@ -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>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment