3#include "ContinuationFutureType.h"
4#include "ContinuationReturnType.h"
11struct IdentityUnwrapper {
12 template <
typename Func>
static Func unwrap(Func&& f) {
13 return std::forward<Func>(f);
16 template <
typename Func>
static Func unwrapShared(Func&& f) {
17 return std::forward<Func>(f);
21template <
typename T>
struct ParameterizedTaskUnwrapper {
22 template <
typename Func>
static auto unwrap(Func&& f) {
23 return [f = std::forward<Func>(f)](T&& t)
mutable {
24 return f(std::move(t))._task;
28 template <
typename Func>
static auto unwrapShared(Func&& f) {
30 [f = std::forward<Func>(f)](
const T& t)
mutable {
return f(t)._task; };
35 template <
typename Func>
static auto unwrap(Func&& f) {
36 return [f = std::forward<Func>(f)]()
mutable {
return f()._task; };
40template <
typename Func,
typename T>
auto unwrapFuture(Func&& f) {
41 return std::conditional<
43 typename ContinuationReturnType<Func, T>::type,
44 typename RemoveFuture<
45 typename ContinuationFutureType<Func, T>::type>::type>::value,
47 ParameterizedTaskUnwrapper<T>>::type::unwrap(std::forward<Func>(f));
50template <
typename Func,
typename T>
auto unwrapSharedFuture(Func&& f) {
51 return std::conditional<
53 typename ContinuationReturnType<Func, T>::type,
54 typename RemoveFuture<
55 typename ContinuationFutureType<Func, T>::type>::type>::value,
57 ParameterizedTaskUnwrapper<T>>::type::unwrapShared(std::forward<Func>(f));
60template <
typename Func>
auto unwrapFuture(Func&& f) {
61 return std::conditional<
63 typename ContinuationReturnType<Func, void>::type,
64 typename RemoveFuture<
65 typename ContinuationFutureType<Func, void>::type>::type>::value,
67 TaskUnwrapper>::type::unwrap(std::forward<Func>(f));
70template <
typename Func>
auto unwrapSharedFuture(Func&& f) {
71 return unwrapFuture(std::forward<Func>(f));
Classes that support asynchronous operations.