123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- #ifndef BOOST_ASIO_EXPERIMENTAL_USE_PROMISE_HPP
- #define BOOST_ASIO_EXPERIMENTAL_USE_PROMISE_HPP
- #if defined(_MSC_VER) && (_MSC_VER >= 1200)
- # pragma once
- #endif
- #include <boost/asio/detail/config.hpp>
- #include <memory>
- #include <boost/asio/detail/type_traits.hpp>
- #include <boost/asio/detail/push_options.hpp>
- namespace boost {
- namespace asio {
- namespace experimental {
- template <typename Allocator = std::allocator<void>>
- struct use_promise_t
- {
-
-
- typedef Allocator allocator_type;
-
- constexpr use_promise_t()
- {
- }
-
- explicit use_promise_t(const Allocator& allocator)
- : allocator_(allocator)
- {
- }
-
- allocator_type get_allocator() const noexcept
- {
- return allocator_;
- }
-
-
- template <typename InnerExecutor>
- struct executor_with_default : InnerExecutor
- {
-
- typedef use_promise_t<Allocator> default_completion_token_type;
-
- executor_with_default(const InnerExecutor& ex) noexcept
- : InnerExecutor(ex)
- {
- }
-
-
- template <typename OtherExecutor>
- executor_with_default(const OtherExecutor& ex,
- constraint_t<
- is_convertible<OtherExecutor, InnerExecutor>::value
- > = 0) noexcept
- : InnerExecutor(ex)
- {
- }
- };
-
-
- template <typename T>
- static typename decay_t<T>::template rebind_executor<
- executor_with_default<typename decay_t<T>::executor_type>
- >::other
- as_default_on(T&& object)
- {
- return typename decay_t<T>::template rebind_executor<
- executor_with_default<typename decay_t<T>::executor_type>
- >::other(static_cast<T&&>(object));
- }
-
- template <typename OtherAllocator>
- use_promise_t<OtherAllocator> rebind(const OtherAllocator& allocator) const
- {
- return use_promise_t<OtherAllocator>(allocator);
- }
- private:
- Allocator allocator_;
- };
- BOOST_ASIO_INLINE_VARIABLE constexpr use_promise_t<> use_promise;
- }
- }
- }
- #include <boost/asio/detail/pop_options.hpp>
- #include <boost/asio/experimental/impl/use_promise.hpp>
- #endif
|