#pragma once #include "ContinuationFutureType.h" #include "ContinuationReturnType.h" namespace CesiumAsync { namespace CesiumImpl { // Begin omitting doxgen warnings for Impl namespace //! @cond Doxygen_Suppress struct IdentityUnwrapper { template static Func unwrap(Func&& f) { return std::forward(f); } template static Func unwrapShared(Func&& f) { return std::forward(f); } }; template struct ParameterizedTaskUnwrapper { template static auto unwrap(Func&& f) { return [f = std::forward(f)](T&& t) mutable { return f(std::move(t))._task; }; } template static auto unwrapShared(Func&& f) { return [f = std::forward(f)](const T& t) mutable { return f(t)._task; }; } }; struct TaskUnwrapper { template static auto unwrap(Func&& f) { return [f = std::forward(f)]() mutable { return f()._task; }; } }; template auto unwrapFuture(Func&& f) { return std::conditional< std::is_same< typename ContinuationReturnType::type, typename RemoveFuture< typename ContinuationFutureType::type>::type>::value, IdentityUnwrapper, ParameterizedTaskUnwrapper>::type::unwrap(std::forward(f)); } template auto unwrapSharedFuture(Func&& f) { return std::conditional< std::is_same< typename ContinuationReturnType::type, typename RemoveFuture< typename ContinuationFutureType::type>::type>::value, IdentityUnwrapper, ParameterizedTaskUnwrapper>::type::unwrapShared(std::forward(f)); } template auto unwrapFuture(Func&& f) { return std::conditional< std::is_same< typename ContinuationReturnType::type, typename RemoveFuture< typename ContinuationFutureType::type>::type>::value, IdentityUnwrapper, TaskUnwrapper>::type::unwrap(std::forward(f)); } template auto unwrapSharedFuture(Func&& f) { return unwrapFuture(std::forward(f)); } //! @endcond // End omitting doxgen warnings for Impl namespace } // namespace CesiumImpl } // namespace CesiumAsync