Difference between revisions of "cpp/coroutine"
From cppreference.com
< cpp
(+) |
Andreas Krug (Talk | contribs) m (fmt) |
||
(7 intermediate revisions by 4 users not shown) | |||
Line 2: | Line 2: | ||
{{cpp/coroutine/navbar}} | {{cpp/coroutine/navbar}} | ||
− | The coroutine support library defines several types that provide compile and run-time support for coroutines. | + | The coroutine support library defines several types that provide compile and run-time support for [[cpp/language/coroutines|coroutines]]. |
===Coroutine traits=== | ===Coroutine traits=== | ||
{{dsc begin}} | {{dsc begin}} | ||
− | {{dsc header | coroutine}} | + | {{dsc header|coroutine}} |
− | {{dsc inc | cpp/coroutine/dsc coroutine_traits}} | + | {{dsc inc|cpp/coroutine/dsc coroutine_traits}} |
{{dsc end}} | {{dsc end}} | ||
===Coroutine handle=== | ===Coroutine handle=== | ||
{{dsc begin}} | {{dsc begin}} | ||
− | {{dsc header | coroutine}} | + | {{dsc header|coroutine}} |
− | {{dsc inc | cpp/coroutine/dsc coroutine_handle}} | + | {{dsc inc|cpp/coroutine/dsc coroutine_handle}} |
{{dsc end}} | {{dsc end}} | ||
===No-op coroutines=== | ===No-op coroutines=== | ||
{{dsc begin}} | {{dsc begin}} | ||
− | {{dsc header | coroutine}} | + | {{dsc header|coroutine}} |
− | {{dsc inc | cpp/coroutine/dsc noop_coroutine}} | + | {{dsc inc|cpp/coroutine/dsc noop_coroutine}} |
− | {{dsc inc | cpp/coroutine/dsc noop_coroutine_promise}} | + | {{dsc inc|cpp/coroutine/dsc noop_coroutine_promise}} |
− | {{dsc inc | cpp/coroutine/dsc noop_coroutine_handle}} | + | {{dsc inc|cpp/coroutine/dsc noop_coroutine_handle}} |
{{dsc end}} | {{dsc end}} | ||
===Trivial awaitables=== | ===Trivial awaitables=== | ||
{{dsc begin}} | {{dsc begin}} | ||
− | {{dsc header | coroutine}} | + | {{dsc header|coroutine}} |
− | {{dsc inc | cpp/coroutine/dsc suspend_never}} | + | {{dsc inc|cpp/coroutine/dsc suspend_never}} |
− | {{dsc inc | cpp/coroutine/dsc suspend_always}} | + | {{dsc inc|cpp/coroutine/dsc suspend_always}} |
{{dsc end}} | {{dsc end}} | ||
− | {{langlinks|ja|zh}} | + | ===Notes=== |
+ | {{ftm begin|std=1|comment=1}} | ||
+ | {{ftm|value=201902L|std=C++20|__cpp_impl_coroutine|{{lt|cpp/language/coroutines|Coroutines}} (compiler support)}} | ||
+ | {{ftm|value=201902L|std=C++20|__cpp_lib_coroutine|[[#top|Coroutines]] (library support)}} | ||
+ | {{ftm|value=202207L|std=C++23|__cpp_lib_generator|{{lc|std::generator}}: synchronous coroutine generator for {{lt|cpp/ranges}}}} | ||
+ | {{ftm end}} | ||
+ | |||
+ | ===See also=== | ||
+ | {{dsc begin}} | ||
+ | {{dsc inc|cpp/ranges/dsc generator}} | ||
+ | {{dsc end}} | ||
+ | |||
+ | {{langlinks|es|ja|ru|zh}} |
Latest revision as of 11:39, 5 November 2023
The coroutine support library defines several types that provide compile and run-time support for coroutines.
Contents |
[edit] Coroutine traits
Defined in header
<coroutine> | |
(C++20) |
trait type for discovering coroutine promise types (class template) |
[edit] Coroutine handle
Defined in header
<coroutine> | |
(C++20) |
used to refer to a suspended or executing coroutine (class template) |
[edit] No-op coroutines
Defined in header
<coroutine> | |
(C++20) |
creates a coroutine handle that has no observable effects when resumed or destroyed (function) |
(C++20) |
used for coroutines with no observable effects (class) |
(C++20) |
std::coroutine_handle<std::noop_coroutine_promise>, intended to refer to a no-op coroutine (typedef) |
[edit] Trivial awaitables
Defined in header
<coroutine> | |
(C++20) |
indicates that an await-expression should never suspend (class) |
(C++20) |
indicates that an await-expression should always suspend (class) |
[edit] Notes
Feature-test macro | Value | Std | Feature |
---|---|---|---|
__cpp_impl_coroutine |
201902L | (C++20) | Coroutines (compiler support) |
__cpp_lib_coroutine |
201902L | (C++20) | Coroutines (library support) |
__cpp_lib_generator |
202207L | (C++23) | std::generator: synchronous coroutine generator for ranges |
[edit] See also
(C++23) |
A view that represents synchronous coroutine generator (class template) |