callableWith<F>::value,
detail::argResult<false, F>,
typename std::conditional<
- callableWith<F, Try<T>&&>::value,
- detail::argResult<true, F, Try<T>&&>,
+ callableWith<F, T&&>::value,
+ detail::argResult<false, F, T&&>,
typename std::conditional<
- callableWith<F, Try<T>&>::value,
- detail::argResult<true, F, Try<T>&>,
+ callableWith<F, T&>::value,
+ detail::argResult<false, F, T&>,
typename std::conditional<
- callableWith<F, T&&>::value,
- detail::argResult<false, F, T&&>,
- detail::argResult<false, F, T&>>::type>::type>::type>::type Arg;
+ callableWith<F, Try<T>&&>::value,
+ detail::argResult<true, F, Try<T>&&>,
+ detail::argResult<true, F, Try<T>&>>::type>::type>::type>::type Arg;
typedef isFuture<typename Arg::Result> ReturnsFuture;
typedef Future<typename ReturnsFuture::Inner> Return;
};
#include <folly/futures/Future.h>
#include <folly/futures/ManualExecutor.h>
#include <folly/futures/DrivableExecutor.h>
+#include <folly/dynamic.h>
#include <folly/MPMCQueue.h>
#include <folly/io/async/EventBase.h>
//auto f2 = []() -> Future<void> { }();
}
+TEST(Future, thenDynamic) {
+ // folly::dynamic has a constructor that takes any T, this test makes
+ // sure that we call the then lambda with folly::dynamic and not
+ // Try<folly::dynamic> because that then fails to compile
+ Promise<folly::dynamic> p;
+ Future<folly::dynamic> f = p.getFuture().then(
+ [](const folly::dynamic& d) {
+ return folly::dynamic(d.asInt() + 3);
+ }
+ );
+ p.setValue(2);
+ EXPECT_EQ(f.get(), 5);
+}
+
TEST(Future, via_then_get_was_racy) {
ThreadExecutor x;
std::unique_ptr<int> val = folly::via(&x)