template <typename Executor = executor>
struct use_awaitable_t
{
+ /// Default constructor.
BOOST_ASIO_CONSTEXPR use_awaitable_t()
{
}
+
+ /// Adapts an executor to add the @c use_awaitable_t completion token as the
+ /// default.
+ template <typename InnerExecutor>
+ struct executor_with_default : InnerExecutor
+ {
+ /// Specify @c use_awaitable_t as the default completion token type.
+ typedef use_awaitable_t default_completion_token_type;
+
+ /// Construct the adapted executor from the inner executor type.
+ executor_with_default(const InnerExecutor& ex) BOOST_ASIO_NOEXCEPT
+ : InnerExecutor(ex)
+ {
+ }
+ };
+
+ /// Type alias to adapt an I/O object to use @c use_awaitable_t as its
+ /// default completion token type.
+#if defined(BOOST_ASIO_HAS_ALIAS_TEMPLATES) \
+ || defined(GENERATING_DOCUMENTATION)
+ template <typename T>
+ using as_default_on_t = typename T::template rebind_executor<
+ executor_with_default<typename T::executor_type> >::other;
+#endif // defined(BOOST_ASIO_HAS_ALIAS_TEMPLATES)
+ // || defined(GENERATING_DOCUMENTATION)
+
+ /// Function helper to adapt an I/O object to use @c use_awaitable_t as its
+ /// default completion token type.
+ template <typename T>
+ static typename T::template rebind_executor<
+ executor_with_default<typename T::executor_type>
+ >::other
+ as_default_on(BOOST_ASIO_MOVE_ARG(T) object)
+ {
+ return typename as_default_on_t<typename decay<T>::type>::type(
+ BOOST_ASIO_MOVE_CAST(T)(object));
+ }
};
/// A completion token object that represents the currently executing coroutine.