mirror of
https://github.com/clearlinux/folly.git
synced 2026-09-01 02:34:43 +00:00
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:
@@ -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>
|
||||
/// 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>
|
||||
|
||||
Reference in New Issue
Block a user