@@ -47,7 +47,7 @@ namespace STDEXEC {
4747 template <class _Sender , class _Promise >
4848 using __value_t = __decay_t <
4949 __value_types_of_t <_Sender, env_of_t <_Promise&>, __q<__single_value>, __msingle_or<void >>
50- >;
50+ >;
5151 } // namespace __detail
5252
5353 // ///////////////////////////////////////////////////////////////////////////
@@ -185,61 +185,62 @@ namespace STDEXEC {
185185 constexpr void return_void () noexcept ;
186186 constexpr auto unhandled_stopped () noexcept -> __std::coroutine_handle<>;
187187 };
188+ } // namespace __as_awaitable
188189
189- struct as_awaitable_t {
190- template <class _Tp , class _Promise >
191- static consteval auto __get_declfn () noexcept {
192- if constexpr (__connect_await::__has_as_awaitable_member<_Tp, _Promise>) {
193- using __result_t = decltype (__declval<_Tp>().as_awaitable (__declval<_Promise&>()));
194- constexpr bool __is_nothrow = noexcept (__declval<_Tp>()
195- .as_awaitable (__declval<_Promise&>()));
196- return __declfn<__result_t , __is_nothrow>();
197- // NOLINTNEXTLINE(bugprone-branch-clone)
198- } else if constexpr (__awaitable<_Tp, __unspecified>) { // NOT __awaitable<_Tp, _Promise> !!
199- return __declfn<_Tp&&>();
200- } else if constexpr (__awaitable_sender<_Tp, _Promise>) {
201- using __result_t = __sender_awaitable<_Promise, _Tp>;
202- constexpr bool __is_nothrow =
203- __nothrow_constructible_from<__result_t , _Tp, __std::coroutine_handle<_Promise>>;
204- return __declfn<__result_t , __is_nothrow>();
205- } else {
206- return __declfn<_Tp&&>();
207- }
208- }
209-
210- template <class _Tp , class _Promise , auto _DeclFn = __get_declfn<_Tp, _Promise>()>
211- requires __callable<__mtypeof<_DeclFn>>
212- auto operator ()(_Tp&& __t , _Promise& __promise) const noexcept (noexcept (_DeclFn()))
213- -> decltype(_DeclFn()) {
214- if constexpr (__connect_await::__has_as_awaitable_member<_Tp, _Promise>) {
215- using __result_t = decltype (static_cast <_Tp&&>(__t ).as_awaitable (__promise));
216- static_assert (__awaitable<__result_t , _Promise>);
217- return static_cast <_Tp&&>(__t ).as_awaitable (__promise);
218- // NOLINTNEXTLINE(bugprone-branch-clone)
219- } else if constexpr (__awaitable<_Tp, __unspecified>) { // NOT __awaitable<_Tp, _Promise> !!
220- return static_cast <_Tp&&>(__t );
221- } else if constexpr (__awaitable_sender<_Tp, _Promise>) {
222- auto __hcoro = __std::coroutine_handle<_Promise>::from_promise (__promise);
223- return __sender_awaitable<_Promise, _Tp>{static_cast <_Tp&&>(__t ), __hcoro};
224- } else {
225- return static_cast <_Tp&&>(__t );
226- }
190+ struct as_awaitable_t {
191+ template <class _Tp , class _Promise >
192+ static consteval auto __get_declfn () noexcept {
193+ using __as_awaitable::__unspecified;
194+ if constexpr (__connect_await::__has_as_awaitable_member<_Tp, _Promise>) {
195+ using __result_t = decltype (__declval<_Tp>().as_awaitable (__declval<_Promise&>()));
196+ constexpr bool __is_nothrow = noexcept (__declval<_Tp>()
197+ .as_awaitable (__declval<_Promise&>()));
198+ return __declfn<__result_t , __is_nothrow>();
199+ // NOLINTNEXTLINE(bugprone-branch-clone)
200+ } else if constexpr (__awaitable<_Tp, __unspecified>) { // NOT __awaitable<_Tp, _Promise> !!
201+ return __declfn<_Tp&&>();
202+ } else if constexpr (__as_awaitable::__awaitable_sender<_Tp, _Promise>) {
203+ using __result_t = __as_awaitable::__sender_awaitable<_Promise, _Tp>;
204+ constexpr bool __is_nothrow =
205+ __nothrow_constructible_from<__result_t , _Tp, __std::coroutine_handle<_Promise>>;
206+ return __declfn<__result_t , __is_nothrow>();
207+ } else {
208+ return __declfn<_Tp&&>();
227209 }
210+ }
228211
229- template <class _Tp , class _Promise , auto _DeclFn = __get_declfn<_Tp, _Promise>()>
230- requires __callable<__mtypeof<_DeclFn>> || __tag_invocable< as_awaitable_t , _Tp, _Promise& >
231- [[deprecated( " the use of tag_invoke for as_awaitable is deprecated " )]]
232- auto operator ()(_Tp&& __t , _Promise& __promise) const
233- noexcept (__nothrow_tag_invocable< as_awaitable_t , _Tp, _Promise&>)
234- -> __tag_invoke_result_t<as_awaitable_t, _Tp, _Promise&> {
235- using __result_t = __tag_invoke_result_t < as_awaitable_t , _Tp, _Promise&> ;
212+ template <class _Tp , class _Promise , auto _DeclFn = __get_declfn<_Tp, _Promise>()>
213+ requires __callable<__mtypeof<_DeclFn>>
214+ auto operator ()(_Tp&& __t , _Promise& __promise) const noexcept ( noexcept (_DeclFn()))
215+ -> decltype(_DeclFn()) {
216+ using __as_awaitable::__unspecified;
217+ if constexpr (__connect_await::__has_as_awaitable_member< _Tp, _Promise>) {
218+ using __result_t = decltype ( static_cast < _Tp&&>( __t ). as_awaitable (__promise)) ;
236219 static_assert (__awaitable<__result_t , _Promise>);
237- return __tag_invoke (*this , static_cast <_Tp&&>(__t ), __promise);
220+ return static_cast <_Tp&&>(__t ).as_awaitable (__promise);
221+ // NOLINTNEXTLINE(bugprone-branch-clone)
222+ } else if constexpr (__awaitable<_Tp, __unspecified>) { // NOT __awaitable<_Tp, _Promise> !!
223+ return static_cast <_Tp&&>(__t );
224+ } else if constexpr (__as_awaitable::__awaitable_sender<_Tp, _Promise>) {
225+ auto __hcoro = __std::coroutine_handle<_Promise>::from_promise (__promise);
226+ return __as_awaitable::__sender_awaitable<_Promise, _Tp>{static_cast <_Tp&&>(__t ), __hcoro};
227+ } else {
228+ return static_cast <_Tp&&>(__t );
238229 }
239- };
240- } // namespace __as_awaitable
230+ }
231+
232+ template <class _Tp , class _Promise , auto _DeclFn = __get_declfn<_Tp, _Promise>()>
233+ requires __callable<__mtypeof<_DeclFn>> || __tag_invocable<as_awaitable_t , _Tp, _Promise&>
234+ [[deprecated(" the use of tag_invoke for as_awaitable is deprecated" )]]
235+ auto operator ()(_Tp&& __t , _Promise& __promise) const
236+ noexcept (__nothrow_tag_invocable<as_awaitable_t , _Tp, _Promise&>)
237+ -> __tag_invoke_result_t<as_awaitable_t, _Tp, _Promise&> {
238+ using __result_t = __tag_invoke_result_t <as_awaitable_t , _Tp, _Promise&>;
239+ static_assert (__awaitable<__result_t , _Promise>);
240+ return __tag_invoke (*this , static_cast <_Tp&&>(__t ), __promise);
241+ }
242+ };
241243
242- using __as_awaitable::as_awaitable_t ;
243244 inline constexpr as_awaitable_t as_awaitable{};
244245#endif
245246} // namespace STDEXEC
0 commit comments