| 1 |
// { dg-additional-options "-fpreprocessed -std=gnu++20 -w -fconcepts" } |
| 2 |
int _M_invoke___functor; |
| 3 |
namespace std { |
| 4 |
template <int __v> struct integral_constant { |
| 5 |
static constexpr bool value = __v; |
| 6 |
}; |
| 7 |
template <typename> struct decay { typedef int type; }; |
| 8 |
template <bool, typename> struct enable_if; |
| 9 |
template <typename _Tp> struct enable_if<true, _Tp> { typedef _Tp type; }; |
| 10 |
template <typename, typename _Fn, typename... _Args> |
| 11 |
void __invoke_impl(_Fn __f, _Args... __args) { |
| 12 |
__f(__args...); |
| 13 |
} |
| 14 |
template <typename, typename _Callable, typename... _Args> |
| 15 |
void __invoke_r(_Callable __fn, _Args... __args) { |
| 16 |
using __result = int; |
| 17 |
using __type = __result; |
| 18 |
__invoke_impl<__type>(__fn, __args...); |
| 19 |
} |
| 20 |
template <typename> class function; |
| 21 |
template <typename _Functor> struct _Base_manager { |
| 22 |
static _Functor *_M_get_pointer(int) {} |
| 23 |
}; |
| 24 |
template <typename, typename> class _Function_handler; |
| 25 |
template <typename _Res, typename _Functor, typename... _ArgTypes> |
| 26 |
struct _Function_handler<_Res(_ArgTypes...), _Functor> { |
| 27 |
static _Res _M_invoke(_ArgTypes... __args) { |
| 28 |
auto __trans_tmp_1 = |
| 29 |
_Base_manager<_Functor>::_M_get_pointer(_M_invoke___functor); |
| 30 |
__invoke_r<_Res>(*__trans_tmp_1, __args...); |
| 31 |
} |
| 32 |
}; |
| 33 |
template <typename _Res, typename... _ArgTypes> |
| 34 |
struct function<_Res(_ArgTypes...)> { |
| 35 |
template <typename _Functor> function(_Functor) { |
| 36 |
_Function_handler<_Res(_ArgTypes...), _Functor>::_M_invoke; |
| 37 |
} |
| 38 |
}; |
| 39 |
template <typename _Tp> struct __shared_ptr_access { |
| 40 |
using element_type = _Tp; |
| 41 |
element_type *operator->(); |
| 42 |
}; |
| 43 |
template <typename> void make_shared(); |
| 44 |
} // namespace std |
| 45 |
namespace boost { |
| 46 |
using std::decay; |
| 47 |
using std::enable_if; |
| 48 |
using std::integral_constant; |
| 49 |
namespace asio { |
| 50 |
namespace detail { |
| 51 |
template <typename> struct is_completion_signature; |
| 52 |
template <typename R, typename... Args> |
| 53 |
struct is_completion_signature<R(Args...)> : integral_constant<true> {}; |
| 54 |
} // namespace detail |
| 55 |
template <typename T> |
| 56 |
concept completion_signature = detail::is_completion_signature<T>::value; |
| 57 |
template <typename...> struct async_result; |
| 58 |
namespace detail { |
| 59 |
template <completion_signature> |
| 60 |
struct async_result_has_initiate_memfn : integral_constant<1> {}; |
| 61 |
} // namespace detail |
| 62 |
template <typename CompletionToken, completion_signature... Signatures, |
| 63 |
typename Initiation> |
| 64 |
enable_if<detail::async_result_has_initiate_memfn<Signatures...>::value, |
| 65 |
decltype(async_result<typename decay<CompletionToken>::type, |
| 66 |
Signatures...>::initiate(0))>::type |
| 67 |
async_initiate(Initiation) {} |
| 68 |
} // namespace asio |
| 69 |
} // namespace boost |
| 70 |
namespace malloy::websocket { |
| 71 |
struct connection { |
| 72 |
auto read(auto, auto done) { |
| 73 |
auto wrapper = [] {}; |
| 74 |
return boost::asio::async_initiate<decltype(done), void()>(wrapper); |
| 75 |
} |
| 76 |
}; |
| 77 |
} // namespace malloy::websocket |
| 78 |
namespace std { |
| 79 |
template <typename...> struct coroutine_traits; |
| 80 |
template <typename = void> struct coroutine_handle { |
| 81 |
operator coroutine_handle<>(); |
| 82 |
static coroutine_handle from_address(void*); |
| 83 |
void* address(); |
| 84 |
}; |
| 85 |
struct suspend_always { |
| 86 |
bool await_ready(); |
| 87 |
void await_suspend(coroutine_handle<>); |
| 88 |
void await_resume(); |
| 89 |
}; |
| 90 |
} // namespace std |
| 91 |
namespace boost { |
| 92 |
namespace asio { |
| 93 |
namespace detail { |
| 94 |
using std::coroutine_handle; |
| 95 |
using std::suspend_always; |
| 96 |
template <typename> class awaitable_frame; |
| 97 |
} // namespace detail |
| 98 |
template <typename, typename = int> struct awaitable { |
| 99 |
bool await_ready(); |
| 100 |
template <class U> |
| 101 |
void await_suspend(detail::coroutine_handle<detail::awaitable_frame<U>>); |
| 102 |
void await_resume(); |
| 103 |
}; |
| 104 |
namespace detail { |
| 105 |
struct awaitable_frame_base { |
| 106 |
auto initial_suspend() { return suspend_always(); } |
| 107 |
auto final_suspend() noexcept { |
| 108 |
struct result { |
| 109 |
bool await_ready() noexcept; |
| 110 |
void await_suspend(coroutine_handle<>) noexcept; |
| 111 |
void await_resume() noexcept; |
| 112 |
}; |
| 113 |
return result{}; |
| 114 |
} |
| 115 |
void unhandled_exception(); |
| 116 |
template <typename T> auto await_transform(T a) { return a; } |
| 117 |
}; |
| 118 |
template <> struct awaitable_frame<void> : awaitable_frame_base { |
| 119 |
awaitable<void> get_return_object(); |
| 120 |
}; |
| 121 |
} // namespace detail |
| 122 |
} // namespace asio |
| 123 |
} // namespace boost |
| 124 |
namespace std { |
| 125 |
template <typename T, typename Executor, typename... Args> |
| 126 |
struct coroutine_traits<boost::asio::awaitable<T, Executor>, Args...> { |
| 127 |
typedef boost::asio::detail::awaitable_frame<T> promise_type; |
| 128 |
}; |
| 129 |
} // namespace std |
| 130 |
namespace boost { |
| 131 |
namespace asio { |
| 132 |
struct use_awaitable_t { |
| 133 |
use_awaitable_t(char, int, char); |
| 134 |
} use_awaitable(0, 0, 0); |
| 135 |
template <typename Executor, typename R, typename... Args> |
| 136 |
struct async_result<Executor, R(Args...)> { |
| 137 |
template <typename Initiation> static awaitable<int> initiate(Initiation); |
| 138 |
}; |
| 139 |
} // namespace asio |
| 140 |
} // namespace boost |
| 141 |
namespace malloy::test { |
| 142 |
void roundtrip_coro(std::function<void(int)>); |
| 143 |
} |
| 144 |
using boost::asio::awaitable; |
| 145 |
template <int> awaitable<void> client_ws_handler_coro() { |
| 146 |
std::__shared_ptr_access<malloy::websocket::connection> conn; |
| 147 |
auto buffer = std::make_shared<int>; |
| 148 |
co_await conn->read(buffer, boost::asio::use_awaitable); |
| 149 |
} |
| 150 |
void port() { |
| 151 |
malloy::test::roundtrip_coro([](auto) { client_ws_handler_coro<false>; }); |
| 152 |
} |