});
}
+template <typename T>
+Later<T>::Later(std::exception_ptr const& eptr) {
+ folly::MoveWrapper<Promise<T>> promise;
+ future_ = promise->getFuture();
+ starter_.getFuture().then([=](Try<void>&& t) mutable {
+ promise->setException(eptr);
+ });
+}
+
+template <typename T>
+template <typename E, class Unused>
+Later<T>::Later(E const& e) :
+ Later<T>::Later(std::make_exception_ptr<E>(e)) {
+}
+
template <class T>
template <class U, class Unused, class Unused2>
Later<T>::Later(std::function<void(std::function<void(U&&)>&&)>&& fn) {
class = typename std::enable_if<std::is_same<T, U>::value>::type>
explicit Later(U&& input);
+ /*
+ * This constructor is used to build an asynchronous workflow that takes an
+ * exception_ptr as input, and throws it on completion.
+ */
+ explicit Later(std::exception_ptr const&);
+
+ /*
+ * This constructor is used to build an asynchronous workflow that takes an
+ * exception as input, and throws it on completion.
+ */
+ template <class E,
+ class = typename std::enable_if<
+ std::is_base_of<std::exception, E>::value>::type>
+ explicit Later(E const& e);
+
/*
* This constructor is used to wrap a pre-existing cob-style asynchronous api
* so that it can be used in wangle. wangle provides the callback to this
EXPECT_TRUE(fulfilled);
}
+TEST(Later, exception_on_launch) {
+ auto later = Later<void>(std::runtime_error("E"));
+ EXPECT_THROW(later.launch().value(), std::runtime_error);
+}
+
TEST(Later, then_value) {
auto future = Later<int>(std::move(1))
.then([](Try<int>&& t) {