#if defined(BOOST_ASIO_HAS_CO_AWAIT) || defined(GENERATING_DOCUMENTATION)
-#include <experimental/coroutine>
-#include <boost/asio/executor.hpp>
+#if defined(BOOST_ASIO_HAS_STD_COROUTINE)
+# include <coroutine>
+#else // defined(BOOST_ASIO_HAS_STD_COROUTINE)
+# include <experimental/coroutine>
+#endif // defined(BOOST_ASIO_HAS_STD_COROUTINE)
+
+#include <boost/asio/any_io_executor.hpp>
#include <boost/asio/detail/push_options.hpp>
namespace asio {
namespace detail {
+#if defined(BOOST_ASIO_HAS_STD_COROUTINE)
+using std::coroutine_handle;
+using std::suspend_always;
+#else // defined(BOOST_ASIO_HAS_STD_COROUTINE)
using std::experimental::coroutine_handle;
using std::experimental::suspend_always;
+#endif // defined(BOOST_ASIO_HAS_STD_COROUTINE)
template <typename> class awaitable_thread;
template <typename, typename> class awaitable_frame;
} // namespace detail
/// The return type of a coroutine or asynchronous operation.
-template <typename T, typename Executor = executor>
+template <typename T, typename Executor = any_io_executor>
class awaitable
{
public:
// Support for co_await keyword.
T await_resume()
{
- return frame_->get();
+ return awaitable(static_cast<awaitable&&>(*this)).frame_->get();
}
#endif // !defined(GENERATING_DOCUMENTATION)