Coroutine support (C++20) - cppreference.com (original) (raw)

C++

Compiler support
Freestanding and hosted
Language
Standard library
Standard library headers
Named requirements
Feature test macros (C++20)
Language support library
Concepts library (C++20)
Diagnostics library
Memory management library
Metaprogramming library (C++11)
General utilities library
Containers library
Iterators library
Ranges library (C++20)
Algorithms library
Strings library
Text processing library
Numerics library
Date and time library
Input/output library
Filesystem library (C++17)
Concurrency support library (C++11)
Execution control library (C++26)
Technical specifications
Symbols index
External libraries

[edit]

Utilities library

Language support Type support (basic types, RTTI) Library feature-test macros (C++20) Program utilities Variadic functions initializer_list(C++11) is_constant_evaluated(C++20) is_within_lifetime(C++26) source_location(C++20) Coroutine support (C++20) Contract support (C++26) Three-way comparison three_way_comparablethree_way_comparable_with(C++20)(C++20) strong_ordering(C++20) weak_ordering(C++20) partial_ordering(C++20) common_comparison_category(C++20) compare_three_way_result(C++20) compare_three_way(C++20) strong_order(C++20) weak_order(C++20) partial_order(C++20) compare_strong_order_fallback(C++20) compare_weak_order_fallback(C++20) compare_partial_order_fallback(C++20) is_eqis_ltis_lteq(C++20)(C++20)(C++20) is_neqis_gtis_gteq(C++20)(C++20)(C++20) General utilities Function objects Bit manipulation (C++20) C-style bit manipulation (C++26) bitset hash(C++11) Relational operators (deprecated in C++20) rel_ops::operator!=rel_ops::operator>rel_ops::operator<=rel_ops::operator>= Integer comparison functions cmp_equalcmp_lesscmp_less_than(C++20)(C++20)(C++20) cmp_not_equalcmp_greatercmp_greater_than(C++20)(C++20)(C++20) in_range(C++20) Swap and type operations swap ranges::swap(C++20) exchange(C++14) declval(C++11) to_underlying(C++23) forward(C++11) forward_like(C++23) move(C++11) move_if_noexcept(C++11) as_const(C++17) Common vocabulary types pair tuple(C++11) optional(C++17) any(C++17) variant(C++17) tuple_size(C++11) tuple_element(C++11) apply(C++17) make_from_tuple(C++17) expected(C++23)

[edit]

Coroutine support

Coroutine traits
coroutine_traits(C++20)
Coroutine handle
coroutine_handle(C++20)
No-op coroutines
noop_coroutine_promise(C++20)
noop_coroutine(C++20)
Trivial awaitables
suspend_never(C++20)
suspend_always(C++20)
Range generators
generator(C++23)

[edit]

The coroutine support library defines several types that provide compile and run-time support for coroutines.

Contents

[edit] Coroutine traits

Defined in header
coroutine_traits(C++20) trait type for discovering coroutine promise types (class template) [edit]

[edit] Coroutine handle

Defined in header
coroutine_handle(C++20) used to refer to a suspended or executing coroutine (class template) [edit]

[edit] No-op coroutines

Defined in header
noop_coroutine(C++20) creates a coroutine handle that has no observable effects when resumed or destroyed (function) [edit]
noop_coroutine_promise(C++20) used for coroutines with no observable effects (class) [edit]
noop_coroutine_handle(C++20) std::coroutine_handle<std::noop_coroutine_promise>, intended to refer to a no-op coroutine (typedef) [edit]

[edit] Trivial awaitables

Defined in header
suspend_never(C++20) indicates that an await-expression should never suspend (class) [edit]
suspend_always(C++20) indicates that an await-expression should always suspend (class) [edit]

[edit] Notes

Feature-test macro Value Std Feature
__cpp_lib_coroutine 201902L (C++20) Coroutine support library

[edit] See also

generator(C++23) A view that represents synchronous coroutine generator (class template) [edit]