Commit 0eb09b75 authored by Eric Niebler's avatar Eric Niebler Committed by Facebook Github Bot

Properly constrain the Future(T2&&) constructor

Summary:
The `Future(T2&&)` constructor is currently constrained to disallow other `Future` and `SemiFuture` types, but it allows types which will cause a hard error when instantiating the body of the constructor. The constructor argument is later used to initialize a `Try<T>`, so the function should properly be constrained with `std::is_constructible<Try<T>, T2>::value`.

Also, add the same constraint to the `SemiFuture(T2&&)` constructor, and to the `FutureBase(T2&&)` constructor for good measure.

Reviewed By: yfeldblum

Differential Revision: D19782313

fbshipit-source-id: 5e1ef5425b0c7ab9cc76c998425e90d0ba0b148f
parent a14c8b75
......@@ -134,7 +134,8 @@ class FutureBase {
class T2 = T,
typename = typename std::enable_if<
!isFuture<typename std::decay<T2>::type>::value &&
!isSemiFuture<typename std::decay<T2>::type>::value>::type>
!isSemiFuture<typename std::decay<T2>::type>::value &&
std::is_constructible<Try<T>, T2>::value>::type>
/* implicit */ FutureBase(T2&& val);
/// Construct a (logical) FutureBase-of-void.
......@@ -511,7 +512,8 @@ class SemiFuture : private futures::detail::FutureBase<T> {
class T2 = T,
typename = typename std::enable_if<
!isFuture<typename std::decay<T2>::type>::value &&
!isSemiFuture<typename std::decay<T2>::type>::value>::type>
!isSemiFuture<typename std::decay<T2>::type>::value &&
std::is_constructible<Try<T>, T2>::value>::type>
/* implicit */ SemiFuture(T2&& val) : Base(std::forward<T2>(val)) {}
/// Construct a (logical) SemiFuture-of-void.
......@@ -1014,7 +1016,8 @@ class Future : private futures::detail::FutureBase<T> {
class T2 = T,
typename = typename std::enable_if<
!isFuture<typename std::decay<T2>::type>::value &&
!isSemiFuture<typename std::decay<T2>::type>::value>::type>
!isSemiFuture<typename std::decay<T2>::type>::value &&
std::is_constructible<Try<T>, T2>::value>::type>
/* implicit */ Future(T2&& val) : Base(std::forward<T2>(val)) {}
/// Construct a (logical) Future-of-void.
......
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