@@ -176,30 +176,6 @@ struct promise_type<void> : promise_base<promise_type<void>> {
176
176
void result_value () const { this ->rethrow_if_exception (); }
177
177
};
178
178
179
- template <typename Promise>
180
- class awaiter_base {
181
- public:
182
- awaiter_base (std::coroutine_handle<Promise> coro) noexcept : m_coroutine(coro) {}
183
-
184
- [[nodiscard]] constexpr bool await_ready () const noexcept { return detail::is_ready (this ->m_coroutine ); }
185
-
186
- auto await_suspend (std::coroutine_handle<> awaiting) noexcept
187
- {
188
- this ->m_coroutine .promise ().set_next (awaiting);
189
- return this ->m_coroutine ;
190
- }
191
-
192
- protected:
193
- auto coroutine ()
194
- {
195
- detail::check_coroutine (this ->m_coroutine );
196
- return this ->m_coroutine ;
197
- }
198
-
199
- private:
200
- std::coroutine_handle<Promise> m_coroutine;
201
- };
202
-
203
179
} // namespace detail
204
180
205
181
// / @endcond
@@ -428,20 +404,32 @@ class [[nodiscard]] task {
428
404
*/
429
405
auto operator co_await () const & noexcept
430
406
{
431
- struct awaiter : public detail ::awaiter_base<promise_type> {
407
+ struct awaiter {
408
+ [[nodiscard]] constexpr bool await_ready () const noexcept { return detail::is_ready (this ->coroutine ); }
409
+
410
+ auto await_suspend (std::coroutine_handle<> awaiting) noexcept
411
+ {
412
+ this ->coroutine .promise ().set_next (awaiting);
413
+ return this ->coroutine ;
414
+ }
415
+
432
416
decltype (auto ) await_resume()
433
417
{
434
- auto & promise = this ->coroutine ().promise ();
418
+ detail::check_coroutine (this ->coroutine );
419
+ auto & promise = this ->coroutine .promise ();
435
420
if constexpr (std::is_rvalue_reference_v<Result>) {
436
421
return std::move (promise.result_value ());
437
422
}
438
423
else {
439
424
return promise.result_value ();
440
425
}
441
426
}
427
+
428
+ // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes)
429
+ std::coroutine_handle<promise_type> coroutine;
442
430
};
443
431
444
- return awaiter ( this ->m_coroutine ) ;
432
+ return awaiter{ this ->m_coroutine } ;
445
433
}
446
434
447
435
/* *
@@ -457,15 +445,26 @@ class [[nodiscard]] task {
457
445
auto operator co_await () && noexcept
458
446
requires (!std::is_void_v<Result>)
459
447
{
460
- struct awaiter : public detail ::awaiter_base<promise_type> {
448
+ struct awaiter {
449
+ [[nodiscard]] constexpr bool await_ready () const noexcept { return detail::is_ready (this ->coroutine ); }
450
+
451
+ auto await_suspend (std::coroutine_handle<> awaiting) noexcept
452
+ {
453
+ this ->coroutine .promise ().set_next (awaiting);
454
+ return this ->coroutine ;
455
+ }
456
+
461
457
decltype (auto ) await_resume()
462
458
{
463
- auto coro = this ->coroutine ( );
464
- return std::move (coro .promise ().result_value ());
459
+ detail::check_coroutine ( this ->coroutine );
460
+ return std::move (this -> coroutine .promise ().result_value ());
465
461
}
462
+
463
+ // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes)
464
+ std::coroutine_handle<promise_type> coroutine;
466
465
};
467
466
468
- return awaiter ( this ->m_coroutine ) ;
467
+ return awaiter{ this ->m_coroutine } ;
469
468
}
470
469
471
470
private:
0 commit comments