File indexing completed on 2025-01-18 09:54:50
0001
0002
0003
0004
0005 #ifndef CPPCORO_DETAIL_IS_AWAITER_HPP_INCLUDED
0006 #define CPPCORO_DETAIL_IS_AWAITER_HPP_INCLUDED
0007
0008 #include <type_traits>
0009 #include <cppcoro/coroutine.hpp>
0010
0011 namespace cppcoro
0012 {
0013 namespace detail
0014 {
0015 template<typename T>
0016 struct is_coroutine_handle
0017 : std::false_type
0018 {};
0019
0020 template<typename PROMISE>
0021 struct is_coroutine_handle<cppcoro::coroutine_handle<PROMISE>>
0022 : std::true_type
0023 {};
0024
0025
0026
0027
0028 template<typename T>
0029 struct is_valid_await_suspend_return_value : std::disjunction<
0030 std::is_void<T>,
0031 std::is_same<T, bool>,
0032 is_coroutine_handle<T>>
0033 {};
0034
0035 template<typename T, typename = std::void_t<>>
0036 struct is_awaiter : std::false_type {};
0037
0038
0039
0040
0041
0042 template<typename T>
0043 struct is_awaiter<T, std::void_t<
0044 decltype(std::declval<T>().await_ready()),
0045 decltype(std::declval<T>().await_suspend(std::declval<cppcoro::coroutine_handle<>>())),
0046 decltype(std::declval<T>().await_resume())>> :
0047 std::conjunction<
0048 std::is_constructible<bool, decltype(std::declval<T>().await_ready())>,
0049 detail::is_valid_await_suspend_return_value<
0050 decltype(std::declval<T>().await_suspend(std::declval<cppcoro::coroutine_handle<>>()))>>
0051 {};
0052 }
0053 }
0054
0055 #endif