123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- #ifndef ASIO_EXPERIMENTAL_IMPL_USE_PROMISE_HPP
- #define ASIO_EXPERIMENTAL_IMPL_USE_PROMISE_HPP
- #if defined(_MSC_VER) && (_MSC_VER >= 1200)
- # pragma once
- #endif
- #include "asio/detail/config.hpp"
- #include <memory>
- #include "asio/async_result.hpp"
- #include "asio/detail/push_options.hpp"
- namespace asio {
- namespace experimental {
- template <typename Allocator>
- struct use_promise_t;
- namespace detail {
- template<typename Signature, typename Executor, typename Allocator>
- struct promise_handler;
- }
- }
- #if !defined(GENERATING_DOCUMENTATION)
- template <typename Allocator, typename R, typename... Args>
- struct async_result<experimental::use_promise_t<Allocator>, R(Args...)>
- {
- template <typename Initiation, typename... InitArgs>
- static auto initiate(Initiation initiation,
- experimental::use_promise_t<Allocator> up, InitArgs... args)
- -> experimental::promise<void(decay_t<Args>...),
- asio::associated_executor_t<Initiation>, Allocator>
- {
- using handler_type = experimental::detail::promise_handler<
- void(decay_t<Args>...),
- asio::associated_executor_t<Initiation>, Allocator>;
- handler_type ht{up.get_allocator(), get_associated_executor(initiation)};
- std::move(initiation)(ht, std::move(args)...);
- return ht.make_promise();
- }
- };
- #endif
- }
- #include "asio/detail/pop_options.hpp"
- #endif
|