Difference between revisions of "cpp/coroutine/suspend always"
From cppreference.com
m (→See also) |
YexuanXiao (Talk | contribs) m |
||
Line 9: | Line 9: | ||
===Member functions=== | ===Member functions=== | ||
{{dsc begin}} | {{dsc begin}} | ||
− | {{dsc mem fun|await_ready|nolink=true | + | {{dsc mem fun|await_ready|nolink=true|indicates that an await expression always suspends}} |
− | {{dsc mem fun|await_suspend|nolink=true | + | {{dsc mem fun|await_suspend|nolink=true|no-op}} |
− | {{dsc mem fun|await_resume|nolink=true | + | {{dsc mem fun|await_resume|nolink=true|no-op}} |
{{dsc end}} | {{dsc end}} | ||
{{member|{{small|std::suspend_always::}}await_ready|2= | {{member|{{small|std::suspend_always::}}await_ready|2= | ||
− | {{ddcl | + | {{ddcl| |
constexpr bool await_ready() const noexcept { return false; } | constexpr bool await_ready() const noexcept { return false; } | ||
}} | }} | ||
Line 23: | Line 23: | ||
{{member|{{small|std::suspend_always::}}await_suspend|2= | {{member|{{small|std::suspend_always::}}await_suspend|2= | ||
− | {{ddcl | + | {{ddcl| |
constexpr void await_suspend( std::coroutine_handle<> ) const noexcept {} | constexpr void await_suspend( std::coroutine_handle<> ) const noexcept {} | ||
}} | }} | ||
Line 31: | Line 31: | ||
{{member|{{small|std::suspend_always::}}await_resume|2= | {{member|{{small|std::suspend_always::}}await_resume|2= | ||
− | {{ddcl | + | {{ddcl| |
constexpr void await_resume() const noexcept {} | constexpr void await_resume() const noexcept {} | ||
}} | }} |
Latest revision as of 14:56, 30 October 2024
Defined in header <coroutine>
|
||
struct suspend_always; |
(since C++20) | |
suspend_always
is an empty class which can be used to indicate that an await expression always suspends and does not produce a value.
Contents |
[edit] Member functions
await_ready |
indicates that an await expression always suspends (public member function) |
await_suspend |
no-op (public member function) |
await_resume |
no-op (public member function) |
std::suspend_always::await_ready
constexpr bool await_ready() const noexcept { return false; } |
||
Always returns false, indicating that an await expression always suspends.
std::suspend_always::await_suspend
constexpr void await_suspend( std::coroutine_handle<> ) const noexcept {} |
||
Does nothing.
std::suspend_always::await_resume
constexpr void await_resume() const noexcept {} |
||
Does nothing. An await expression does not produce a value if suspend_always
is used.
[edit] Example
This section is incomplete Reason: no example |
[edit] See also
(C++20) |
indicates that an await-expression should never suspend (class) |