File indexing completed on 2025-01-18 09:54:50
0001
0002
0003
0004
0005 #ifndef CPPCORO_DETAIL_GET_AWAITER_HPP_INCLUDED
0006 #define CPPCORO_DETAIL_GET_AWAITER_HPP_INCLUDED
0007
0008 #include <cppcoro/detail/is_awaiter.hpp>
0009 #include <cppcoro/detail/any.hpp>
0010
0011 namespace cppcoro
0012 {
0013 namespace detail
0014 {
0015 template<typename T>
0016 auto get_awaiter_impl(T&& value, int)
0017 noexcept(noexcept(static_cast<T&&>(value).operator co_await()))
0018 -> decltype(static_cast<T&&>(value).operator co_await())
0019 {
0020 return static_cast<T&&>(value).operator co_await();
0021 }
0022
0023 template<typename T>
0024 auto get_awaiter_impl(T&& value, long)
0025 noexcept(noexcept(operator co_await(static_cast<T&&>(value))))
0026 -> decltype(operator co_await(static_cast<T&&>(value)))
0027 {
0028 return operator co_await(static_cast<T&&>(value));
0029 }
0030
0031 template<
0032 typename T,
0033 std::enable_if_t<cppcoro::detail::is_awaiter<T&&>::value, int> = 0>
0034 T&& get_awaiter_impl(T&& value, cppcoro::detail::any) noexcept
0035 {
0036 return static_cast<T&&>(value);
0037 }
0038
0039 template<typename T>
0040 auto get_awaiter(T&& value)
0041 noexcept(noexcept(detail::get_awaiter_impl(static_cast<T&&>(value), 123)))
0042 -> decltype(detail::get_awaiter_impl(static_cast<T&&>(value), 123))
0043 {
0044 return detail::get_awaiter_impl(static_cast<T&&>(value), 123);
0045 }
0046 }
0047 }
0048
0049 #endif