Namespaces
Variants
Views
Actions

Difference between revisions of "cpp/coroutine/suspend always"

From cppreference.com
< cpp‎ | coroutine
m (added Spanish link)
Line 24: Line 24:
 
{{member | {{small|std::suspend_always::}}await_suspend | 2=
 
{{member | {{small|std::suspend_always::}}await_suspend | 2=
 
{{ddcl | since=c++20 |
 
{{ddcl | since=c++20 |
constexpr void await_suspend() const noexcept {}
+
constexpr void await_suspend(std::coroutine_handle<>) const noexcept {}
 
}}
 
}}
  

Revision as of 11:02, 18 July 2021

 
 
Utilities library
General utilities
Relational operators (deprecated in C++20)
 
Coroutine support
Coroutine traits
Coroutine handle
No-op coroutines
Trivial awaitables
suspend_always
(C++20)
Range generators
(C++23)
 
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

Member functions

await_ready
(C++20)
indicates that an await expression always suspends
(public member function)
await_suspend
(C++20)
no-op
(public member function)
await_resume
(C++20)
no-op
(public member function)

std::suspend_always::await_ready

constexpr bool await_ready() const noexcept { return false; }
(since C++20)

Always returns false, indicating that an await expression always suspends.

std::suspend_always::await_suspend

constexpr void await_suspend(std::coroutine_handle<>) const noexcept {}
(since C++20)

Does nothing.

std::suspend_always::await_resume

constexpr void await_resume() const noexcept {}
(since C++20)

Does nothing. An await expression does not produce a value if suspend_always is used.

Example

See also

indicates that an await-expression should never suspend
(class) [edit]