File indexing completed on 2024-11-15 09:03:04
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef BOOST_ASIO_EXPERIMENTAL_USE_PROMISE_HPP
0013 #define BOOST_ASIO_EXPERIMENTAL_USE_PROMISE_HPP
0014
0015 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
0016 # pragma once
0017 #endif
0018
0019 #include <boost/asio/detail/config.hpp>
0020 #include <memory>
0021 #include <boost/asio/detail/type_traits.hpp>
0022
0023 #include <boost/asio/detail/push_options.hpp>
0024
0025 namespace boost {
0026 namespace asio {
0027 namespace experimental {
0028
0029 template <typename Allocator = std::allocator<void>>
0030 struct use_promise_t
0031 {
0032
0033
0034 typedef Allocator allocator_type;
0035
0036
0037 constexpr use_promise_t()
0038 {
0039 }
0040
0041
0042 explicit use_promise_t(const Allocator& allocator)
0043 : allocator_(allocator)
0044 {
0045 }
0046
0047
0048 allocator_type get_allocator() const noexcept
0049 {
0050 return allocator_;
0051 }
0052
0053
0054
0055 template <typename InnerExecutor>
0056 struct executor_with_default : InnerExecutor
0057 {
0058
0059 typedef use_promise_t<Allocator> default_completion_token_type;
0060
0061
0062 executor_with_default(const InnerExecutor& ex) noexcept
0063 : InnerExecutor(ex)
0064 {
0065 }
0066
0067
0068
0069 template <typename OtherExecutor>
0070 executor_with_default(const OtherExecutor& ex,
0071 constraint_t<
0072 is_convertible<OtherExecutor, InnerExecutor>::value
0073 > = 0) noexcept
0074 : InnerExecutor(ex)
0075 {
0076 }
0077 };
0078
0079
0080
0081 template <typename T>
0082 static typename decay_t<T>::template rebind_executor<
0083 executor_with_default<typename decay_t<T>::executor_type>
0084 >::other
0085 as_default_on(T&& object)
0086 {
0087 return typename decay_t<T>::template rebind_executor<
0088 executor_with_default<typename decay_t<T>::executor_type>
0089 >::other(static_cast<T&&>(object));
0090 }
0091
0092
0093 template <typename OtherAllocator>
0094 use_promise_t<OtherAllocator> rebind(const OtherAllocator& allocator) const
0095 {
0096 return use_promise_t<OtherAllocator>(allocator);
0097 }
0098
0099 private:
0100 Allocator allocator_;
0101 };
0102
0103 constexpr use_promise_t<> use_promise;
0104
0105 }
0106 }
0107 }
0108
0109 #include <boost/asio/detail/pop_options.hpp>
0110
0111 #include <boost/asio/experimental/impl/use_promise.hpp>
0112
0113 #endif