// // experimental/impl/use_promise.hpp // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // Copyright (c) 2021-2022 Klemens D. Morgenstern // (klemens dot morgenstern at gmx dot net) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // #ifndef ASIO_EXPERIMENTAL_IMPL_USE_PROMISE_HPP #define ASIO_EXPERIMENTAL_IMPL_USE_PROMISE_HPP #if defined(_MSC_VER) && (_MSC_VER >= 1200) # pragma once #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) #include "asio/detail/config.hpp" #include #include "asio/async_result.hpp" #include "asio/detail/push_options.hpp" namespace asio { namespace experimental { template struct use_promise_t; namespace detail { template struct promise_handler; } // namespace detail } // namespace experimental #if !defined(GENERATING_DOCUMENTATION) template struct async_result, R(Args...)> { template static auto initiate(Initiation initiation, experimental::use_promise_t up, InitArgs... args) -> experimental::promise::type...), asio::associated_executor_t, Allocator> { using handler_type = experimental::detail::promise_handler< void(typename decay::type...), asio::associated_executor_t, Allocator>; handler_type ht{up.get_allocator(), get_associated_executor(initiation)}; std::move(initiation)(ht, std::move(args)...); return ht.make_promise(); } }; #endif // !defined(GENERATING_DOCUMENTATION) } // namespace asio #include "asio/detail/pop_options.hpp" #endif // ASIO_EXPERIMENTAL_IMPL_USE_PROMISE_HPP