This commit is contained in:
2025-10-25 03:02:53 +03:00
commit 043225d523
3416 changed files with 681196 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
[coroutine.generator.overview]
# 25 Ranges library [[ranges]](./#ranges)
## 25.8 Range generators [[coro.generator]](coro.generator#coroutine.generator.overview)
### 25.8.1 Overview [coroutine.generator.overview]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L18041)
Class template generator presents
a view of the elements yielded by the evaluation of a coroutine[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L18045)
A generator generates a sequence of elements by
repeatedly resuming the coroutine from which it was returned[.](#2.sentence-1)
Elements of the sequence are produced by the coroutine
each time a co_yield statement is evaluated[.](#2.sentence-2)
When the co_yield statement is of the formco_yield elements_of(r),
each element of the range r is successively produced as an element of the sequence[.](#2.sentence-3)
[*Example [1](#example-1)*: generator<int> ints(int start = 0) {while (true)co_yield start++;}void f() {for (auto i : ints() | views::take(3)) cout << i << ' '; // prints 0 1 2} — *end example*]

View File

@@ -0,0 +1,300 @@
[coroutine.handle]
# 17 Language support library [[support]](./#support)
## 17.13 Coroutines [[support.coroutine]](support.coroutine#coroutine.handle)
### 17.13.4 Class template coroutine_handle [coroutine.handle]
#### [17.13.4.1](#general) General [[coroutine.handle.general]](coroutine.handle.general)
[🔗](#lib:coroutine_handle)
namespace std {template<>struct coroutine_handle<void>{// [[coroutine.handle.con]](#con "17.13.4.2Construct/reset"), construct/resetconstexpr coroutine_handle() noexcept; constexpr coroutine_handle(nullptr_t) noexcept;
coroutine_handle& operator=(nullptr_t) noexcept; // [[coroutine.handle.export.import]](#export.import "17.13.4.4Export/import"), export/importconstexpr void* address() const noexcept; static constexpr coroutine_handle from_address(void* addr); // [[coroutine.handle.observers]](#observers "17.13.4.5Observers"), observersconstexpr explicit operator bool() const noexcept; bool done() const; // [[coroutine.handle.resumption]](#resumption "17.13.4.6Resumption"), resumptionvoid operator()() const; void resume() const; void destroy() const; private:void* ptr; // *exposition only*}; template<class Promise>struct coroutine_handle {// [[coroutine.handle.con]](#con "17.13.4.2Construct/reset"), construct/resetconstexpr coroutine_handle() noexcept; constexpr coroutine_handle(nullptr_t) noexcept; static coroutine_handle from_promise(Promise&);
coroutine_handle& operator=(nullptr_t) noexcept; // [[coroutine.handle.export.import]](#export.import "17.13.4.4Export/import"), export/importconstexpr void* address() const noexcept; static constexpr coroutine_handle from_address(void* addr); // [[coroutine.handle.conv]](#conv "17.13.4.3Conversion"), conversionconstexpr operator coroutine_handle<>() const noexcept; // [[coroutine.handle.observers]](#observers "17.13.4.5Observers"), observersconstexpr explicit operator bool() const noexcept; bool done() const; // [[coroutine.handle.resumption]](#resumption "17.13.4.6Resumption"), resumptionvoid operator()() const; void resume() const; void destroy() const; // [[coroutine.handle.promise]](#promise "17.13.4.7Promise access"), promise access Promise& promise() const; private:void* ptr; // *exposition only*};}
[1](#general-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L5892)
An object of typecoroutine_handle<T> is called a [*coroutine handle*](#def:coroutine_handle) and can be used to refer to a suspended or executing coroutine[.](#general-1.sentence-1)
A coroutine_handle object whose
member address() returns a null pointer value
does not refer to any
coroutine[.](#general-1.sentence-2)
Two coroutine_handle objects refer to the same coroutine
if and only if their member address() returns the same non-null value[.](#general-1.sentence-3)
[2](#general-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L5903)
If a program declares an explicit or partial specialization ofcoroutine_handle, the behavior is undefined[.](#general-2.sentence-1)
#### [17.13.4.2](#con) Construct/reset [[coroutine.handle.con]](coroutine.handle.con)
[🔗](#lib:coroutine_handle,constructor)
`constexpr coroutine_handle() noexcept;
constexpr coroutine_handle(nullptr_t) noexcept;
`
[1](#con-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L5916)
*Postconditions*: address() == nullptr[.](#con-1.sentence-1)
[🔗](#lib:from_promise,coroutine_handle)
`static coroutine_handle from_promise(Promise& p);
`
[2](#con-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L5927)
*Preconditions*: p is a reference to a promise object of a coroutine[.](#con-2.sentence-1)
[3](#con-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L5931)
*Postconditions*: addressof(h.promise()) == addressof(p)[.](#con-3.sentence-1)
[4](#con-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L5935)
*Returns*: A coroutine handle h referring to the coroutine[.](#con-4.sentence-1)
[🔗](#lib:operator=,coroutine_handle)
`coroutine_handle& operator=(nullptr_t) noexcept;
`
[5](#con-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L5946)
*Postconditions*: address() == nullptr[.](#con-5.sentence-1)
[6](#con-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L5950)
*Returns*: *this[.](#con-6.sentence-1)
#### [17.13.4.3](#conv) Conversion [[coroutine.handle.conv]](coroutine.handle.conv)
[🔗](#lib:operator_coroutine_handle%3c%3e,coroutine_handle)
`constexpr operator coroutine_handle<>() const noexcept;
`
[1](#conv-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L5963)
*Effects*: Equivalent to: return coroutine_handle<>::from_address(address());
#### [17.13.4.4](#export.import) Export/import [[coroutine.handle.export.import]](coroutine.handle.export.import)
[🔗](#lib:address,coroutine_handle)
`constexpr void* address() const noexcept;
`
[1](#export.import-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L5976)
*Returns*: ptr[.](#export.import-1.sentence-1)
[🔗](#lib:from_address,coroutine_handle)
`static constexpr coroutine_handle<> coroutine_handle<>::from_address(void* addr);
`
[2](#export.import-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L5987)
*Preconditions*: addr was obtained via a prior call to address on an object whose type is a specialization of coroutine_handle[.](#export.import-2.sentence-1)
[3](#export.import-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L5992)
*Postconditions*: from_address(address()) == *this[.](#export.import-3.sentence-1)
[🔗](#lib:from_address,coroutine_handle_)
`static constexpr coroutine_handle<Promise> coroutine_handle<Promise>::from_address(void* addr);
`
[4](#export.import-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6003)
*Preconditions*: addr was obtained via a prior call to address on an object of type cv coroutine_handle<Promise>[.](#export.import-4.sentence-1)
[5](#export.import-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6008)
*Postconditions*: from_address(address()) == *this[.](#export.import-5.sentence-1)
#### [17.13.4.5](#observers) Observers [[coroutine.handle.observers]](coroutine.handle.observers)
[🔗](#lib:operator_bool,coroutine_handle)
`constexpr explicit operator bool() const noexcept;
`
[1](#observers-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6021)
*Returns*: address() != nullptr[.](#observers-1.sentence-1)
[🔗](#lib:done,coroutine_handle)
`bool done() const;
`
[2](#observers-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6032)
*Preconditions*: *this refers to a suspended coroutine[.](#observers-2.sentence-1)
[3](#observers-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6036)
*Returns*: true if the coroutine is suspended at its
final suspend point, otherwise false[.](#observers-3.sentence-1)
#### [17.13.4.6](#resumption) Resumption [[coroutine.handle.resumption]](coroutine.handle.resumption)
[1](#resumption-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6044)
Resuming a coroutine via resume, operator(), or destroy on an execution agent other than the one on which it was suspended
has implementation-defined behavior
unless
each execution agent either is
an instance of std::thread or std::jthread,
or is the thread that executes main[.](#resumption-1.sentence-1)
[*Note [1](#resumption-note-1)*:
A coroutine that is resumed on a different execution agent should
avoid relying on consistent thread identity throughout, such as holding
a mutex object across a suspend point[.](#resumption-1.sentence-2)
— *end note*]
[*Note [2](#resumption-note-2)*:
A concurrent resumption of the coroutine can result in a data race[.](#resumption-1.sentence-3)
— *end note*]
[🔗](#lib:operator(),coroutine_handle)
`void operator()() const;
void resume() const;
`
[2](#resumption-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6069)
*Preconditions*: *this refers to a suspended coroutine[.](#resumption-2.sentence-1)
The coroutine is not suspended at its final suspend point[.](#resumption-2.sentence-2)
[3](#resumption-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6074)
*Effects*: Resumes the execution of the coroutine[.](#resumption-3.sentence-1)
[🔗](#lib:destroy,coroutine_handle)
`void destroy() const;
`
[4](#resumption-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6085)
*Preconditions*: *this refers to a suspended coroutine[.](#resumption-4.sentence-1)
[5](#resumption-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6089)
*Effects*: Destroys the coroutine ([[dcl.fct.def.coroutine]](dcl.fct.def.coroutine "9.6.4Coroutine definitions"))[.](#resumption-5.sentence-1)
#### [17.13.4.7](#promise) Promise access [[coroutine.handle.promise]](coroutine.handle.promise)
[🔗](#lib:promise,coroutine_handle)
`Promise& promise() const;
`
[1](#promise-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6102)
*Preconditions*: *this refers to a coroutine[.](#promise-1.sentence-1)
[2](#promise-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6106)
*Returns*: A reference to the promise of the coroutine[.](#promise-2.sentence-1)
#### [17.13.4.8](#compare) Comparison operators [[coroutine.handle.compare]](coroutine.handle.compare)
[🔗](#lib:operator==,coroutine_handle)
`constexpr bool operator==(coroutine_handle<> x, coroutine_handle<> y) noexcept;
`
[1](#compare-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6120)
*Returns*: x.address() == y.address()[.](#compare-1.sentence-1)
[🔗](#lib:operator%3c=%3e,coroutine_handle)
`constexpr strong_ordering operator<=>(coroutine_handle<> x, coroutine_handle<> y) noexcept;
`
[2](#compare-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6131)
*Returns*: compare_three_way()(x.address(), y.address())[.](#compare-2.sentence-1)
#### [17.13.4.9](#hash) Hash support [[coroutine.handle.hash]](coroutine.handle.hash)
[🔗](#lib:hash,coroutine_handle)
`template<class P> struct hash<coroutine_handle<P>>;
`
[1](#hash-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6144)
The specialization is enabled ([[unord.hash]](unord.hash "22.10.19Class template hash"))[.](#hash-1.sentence-1)

View File

@@ -0,0 +1,31 @@
[coroutine.handle.compare]
# 17 Language support library [[support]](./#support)
## 17.13 Coroutines [[support.coroutine]](support.coroutine#coroutine.handle.compare)
### 17.13.4 Class template coroutine_handle [[coroutine.handle]](coroutine.handle#compare)
#### 17.13.4.8 Comparison operators [coroutine.handle.compare]
[🔗](#lib:operator==,coroutine_handle)
`constexpr bool operator==(coroutine_handle<> x, coroutine_handle<> y) noexcept;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6120)
*Returns*: x.address() == y.address()[.](#1.sentence-1)
[🔗](#lib:operator%3c=%3e,coroutine_handle)
`constexpr strong_ordering operator<=>(coroutine_handle<> x, coroutine_handle<> y) noexcept;
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6131)
*Returns*: compare_three_way()(x.address(), y.address())[.](#2.sentence-1)

View File

@@ -0,0 +1,61 @@
[coroutine.handle.con]
# 17 Language support library [[support]](./#support)
## 17.13 Coroutines [[support.coroutine]](support.coroutine#coroutine.handle.con)
### 17.13.4 Class template coroutine_handle [[coroutine.handle]](coroutine.handle#con)
#### 17.13.4.2 Construct/reset [coroutine.handle.con]
[🔗](#lib:coroutine_handle,constructor)
`constexpr coroutine_handle() noexcept;
constexpr coroutine_handle(nullptr_t) noexcept;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L5916)
*Postconditions*: address() == nullptr[.](#1.sentence-1)
[🔗](#lib:from_promise,coroutine_handle)
`static coroutine_handle from_promise(Promise& p);
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L5927)
*Preconditions*: p is a reference to a promise object of a coroutine[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L5931)
*Postconditions*: addressof(h.promise()) == addressof(p)[.](#3.sentence-1)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L5935)
*Returns*: A coroutine handle h referring to the coroutine[.](#4.sentence-1)
[🔗](#lib:operator=,coroutine_handle)
`coroutine_handle& operator=(nullptr_t) noexcept;
`
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L5946)
*Postconditions*: address() == nullptr[.](#5.sentence-1)
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L5950)
*Returns*: *this[.](#6.sentence-1)

View File

@@ -0,0 +1,20 @@
[coroutine.handle.conv]
# 17 Language support library [[support]](./#support)
## 17.13 Coroutines [[support.coroutine]](support.coroutine#coroutine.handle.conv)
### 17.13.4 Class template coroutine_handle [[coroutine.handle]](coroutine.handle#conv)
#### 17.13.4.3 Conversion [coroutine.handle.conv]
[🔗](#lib:operator_coroutine_handle%3c%3e,coroutine_handle)
`constexpr operator coroutine_handle<>() const noexcept;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L5963)
*Effects*: Equivalent to: return coroutine_handle<>::from_address(address());

View File

@@ -0,0 +1,54 @@
[coroutine.handle.export.import]
# 17 Language support library [[support]](./#support)
## 17.13 Coroutines [[support.coroutine]](support.coroutine#coroutine.handle.export.import)
### 17.13.4 Class template coroutine_handle [[coroutine.handle]](coroutine.handle#export.import)
#### 17.13.4.4 Export/import [coroutine.handle.export.import]
[🔗](#lib:address,coroutine_handle)
`constexpr void* address() const noexcept;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L5976)
*Returns*: ptr[.](#1.sentence-1)
[🔗](#lib:from_address,coroutine_handle)
`static constexpr coroutine_handle<> coroutine_handle<>::from_address(void* addr);
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L5987)
*Preconditions*: addr was obtained via a prior call to address on an object whose type is a specialization of coroutine_handle[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L5992)
*Postconditions*: from_address(address()) == *this[.](#3.sentence-1)
[🔗](#lib:from_address,coroutine_handle_)
`static constexpr coroutine_handle<Promise> coroutine_handle<Promise>::from_address(void* addr);
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6003)
*Preconditions*: addr was obtained via a prior call to address on an object of type cv coroutine_handle<Promise>[.](#4.sentence-1)
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6008)
*Postconditions*: from_address(address()) == *this[.](#5.sentence-1)

View File

@@ -0,0 +1,35 @@
[coroutine.handle.general]
# 17 Language support library [[support]](./#support)
## 17.13 Coroutines [[support.coroutine]](support.coroutine#coroutine.handle.general)
### 17.13.4 Class template coroutine_handle [[coroutine.handle]](coroutine.handle#general)
#### 17.13.4.1 General [coroutine.handle.general]
[🔗](#lib:coroutine_handle)
namespace std {template<>struct coroutine_handle<void>{// [[coroutine.handle.con]](coroutine.handle.con "17.13.4.2Construct/reset"), construct/resetconstexpr coroutine_handle() noexcept; constexpr coroutine_handle(nullptr_t) noexcept;
coroutine_handle& operator=(nullptr_t) noexcept; // [[coroutine.handle.export.import]](coroutine.handle.export.import "17.13.4.4Export/import"), export/importconstexpr void* address() const noexcept; static constexpr coroutine_handle from_address(void* addr); // [[coroutine.handle.observers]](coroutine.handle.observers "17.13.4.5Observers"), observersconstexpr explicit operator bool() const noexcept; bool done() const; // [[coroutine.handle.resumption]](coroutine.handle.resumption "17.13.4.6Resumption"), resumptionvoid operator()() const; void resume() const; void destroy() const; private:void* ptr; // *exposition only*}; template<class Promise>struct coroutine_handle {// [[coroutine.handle.con]](coroutine.handle.con "17.13.4.2Construct/reset"), construct/resetconstexpr coroutine_handle() noexcept; constexpr coroutine_handle(nullptr_t) noexcept; static coroutine_handle from_promise(Promise&);
coroutine_handle& operator=(nullptr_t) noexcept; // [[coroutine.handle.export.import]](coroutine.handle.export.import "17.13.4.4Export/import"), export/importconstexpr void* address() const noexcept; static constexpr coroutine_handle from_address(void* addr); // [[coroutine.handle.conv]](coroutine.handle.conv "17.13.4.3Conversion"), conversionconstexpr operator coroutine_handle<>() const noexcept; // [[coroutine.handle.observers]](coroutine.handle.observers "17.13.4.5Observers"), observersconstexpr explicit operator bool() const noexcept; bool done() const; // [[coroutine.handle.resumption]](coroutine.handle.resumption "17.13.4.6Resumption"), resumptionvoid operator()() const; void resume() const; void destroy() const; // [[coroutine.handle.promise]](coroutine.handle.promise "17.13.4.7Promise access"), promise access Promise& promise() const; private:void* ptr; // *exposition only*};}
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L5892)
An object of typecoroutine_handle<T> is called a [*coroutine handle*](#def:coroutine_handle) and can be used to refer to a suspended or executing coroutine[.](#1.sentence-1)
A coroutine_handle object whose
member address() returns a null pointer value
does not refer to any
coroutine[.](#1.sentence-2)
Two coroutine_handle objects refer to the same coroutine
if and only if their member address() returns the same non-null value[.](#1.sentence-3)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L5903)
If a program declares an explicit or partial specialization ofcoroutine_handle, the behavior is undefined[.](#2.sentence-1)

View File

@@ -0,0 +1,20 @@
[coroutine.handle.hash]
# 17 Language support library [[support]](./#support)
## 17.13 Coroutines [[support.coroutine]](support.coroutine#coroutine.handle.hash)
### 17.13.4 Class template coroutine_handle [[coroutine.handle]](coroutine.handle#hash)
#### 17.13.4.9 Hash support [coroutine.handle.hash]
[🔗](#lib:hash,coroutine_handle)
`template<class P> struct hash<coroutine_handle<P>>;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6144)
The specialization is enabled ([[unord.hash]](unord.hash "22.10.19Class template hash"))[.](#1.sentence-1)

View File

@@ -0,0 +1,109 @@
[coroutine.handle.noop]
# 17 Language support library [[support]](./#support)
## 17.13 Coroutines [[support.coroutine]](support.coroutine#coroutine.handle.noop)
### 17.13.5 No-op coroutines [[coroutine.noop]](coroutine.noop#coroutine.handle.noop)
#### 17.13.5.2 Class coroutine_handle<noop_coroutine_promise> [coroutine.handle.noop]
#### [17.13.5.2.1](#general) General [[coroutine.handle.noop.general]](coroutine.handle.noop.general)
[🔗](#lib:coroutine_handle%3cnoop_coroutine_promise%3e)
namespace std {template<>struct coroutine_handle<noop_coroutine_promise>{// [[coroutine.handle.noop.conv]](#conv "17.13.5.2.2Conversion"), conversionconstexpr operator coroutine_handle<>() const noexcept; // [[coroutine.handle.noop.observers]](#observers "17.13.5.2.3Observers"), observersconstexpr explicit operator bool() const noexcept; constexpr bool done() const noexcept; // [[coroutine.handle.noop.resumption]](#resumption "17.13.5.2.4Resumption"), resumptionconstexpr void operator()() const noexcept; constexpr void resume() const noexcept; constexpr void destroy() const noexcept; // [[coroutine.handle.noop.promise]](#promise "17.13.5.2.5Promise access"), promise access noop_coroutine_promise& promise() const noexcept; // [[coroutine.handle.noop.address]](#address "17.13.5.2.6Address"), addressconstexpr void* address() const noexcept; private: coroutine_handle(*unspecified*); void* ptr; // *exposition only*};}
#### [17.13.5.2.2](#conv) Conversion [[coroutine.handle.noop.conv]](coroutine.handle.noop.conv)
[🔗](#lib:operator_coroutine_handle%3c%3e,coroutine_handle%3cnoop_coroutine_promise%3e)
`constexpr operator coroutine_handle<>() const noexcept;
`
[1](#conv-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6206)
*Effects*: Equivalent to: return coroutine_handle<>::from_address(address());
#### [17.13.5.2.3](#observers) Observers [[coroutine.handle.noop.observers]](coroutine.handle.noop.observers)
[🔗](#lib:operator_bool,coroutine_handle%3cnoop_coroutine_promise%3e)
`constexpr explicit operator bool() const noexcept;
`
[1](#observers-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6219)
*Returns*: true[.](#observers-1.sentence-1)
[🔗](#lib:done,coroutine_handle%3cnoop_coroutine_promise%3e)
`constexpr bool done() const noexcept;
`
[2](#observers-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6230)
*Returns*: false[.](#observers-2.sentence-1)
#### [17.13.5.2.4](#resumption) Resumption [[coroutine.handle.noop.resumption]](coroutine.handle.noop.resumption)
[🔗](#lib:operator(),coroutine_handle%3cnoop_coroutine_promise%3e)
`constexpr void operator()() const noexcept;
constexpr void resume() const noexcept;
constexpr void destroy() const noexcept;
`
[1](#resumption-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6247)
*Effects*: None[.](#resumption-1.sentence-1)
[2](#resumption-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6251)
*Remarks*: If noop_coroutine_handle is converted to coroutine_handle<>,
calls to operator(), resume and destroy on that handle
will also have no observable effects[.](#resumption-2.sentence-1)
#### [17.13.5.2.5](#promise) Promise access [[coroutine.handle.noop.promise]](coroutine.handle.noop.promise)
[🔗](#lib:promise,coroutine_handle%3cnoop_coroutine_promise%3e)
`noop_coroutine_promise& promise() const noexcept;
`
[1](#promise-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6266)
*Returns*: A reference to the promise object associated with this
coroutine handle[.](#promise-1.sentence-1)
#### [17.13.5.2.6](#address) Address [[coroutine.handle.noop.address]](coroutine.handle.noop.address)
[🔗](#lib:address,coroutine_handle%3cnoop_coroutine_promise%3e)
`constexpr void* address() const noexcept;
`
[1](#address-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6280)
*Returns*: ptr[.](#address-1.sentence-1)
[2](#address-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6284)
*Remarks*: A noop_coroutine_handle's ptr is always a
non-null pointer value[.](#address-2.sentence-1)

View File

@@ -0,0 +1,29 @@
[coroutine.handle.noop.address]
# 17 Language support library [[support]](./#support)
## 17.13 Coroutines [[support.coroutine]](support.coroutine#coroutine.handle.noop.address)
### 17.13.5 No-op coroutines [[coroutine.noop]](coroutine.noop#coroutine.handle.noop.address)
#### 17.13.5.2 Class coroutine_handle<noop_coroutine_promise> [[coroutine.handle.noop]](coroutine.handle.noop#address)
#### 17.13.5.2.6 Address [coroutine.handle.noop.address]
[🔗](#lib:address,coroutine_handle%3cnoop_coroutine_promise%3e)
`constexpr void* address() const noexcept;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6280)
*Returns*: ptr[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6284)
*Remarks*: A noop_coroutine_handle's ptr is always a
non-null pointer value[.](#2.sentence-1)

View File

@@ -0,0 +1,22 @@
[coroutine.handle.noop.conv]
# 17 Language support library [[support]](./#support)
## 17.13 Coroutines [[support.coroutine]](support.coroutine#coroutine.handle.noop.conv)
### 17.13.5 No-op coroutines [[coroutine.noop]](coroutine.noop#coroutine.handle.noop.conv)
#### 17.13.5.2 Class coroutine_handle<noop_coroutine_promise> [[coroutine.handle.noop]](coroutine.handle.noop#conv)
#### 17.13.5.2.2 Conversion [coroutine.handle.noop.conv]
[🔗](#lib:operator_coroutine_handle%3c%3e,coroutine_handle%3cnoop_coroutine_promise%3e)
`constexpr operator coroutine_handle<>() const noexcept;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6206)
*Effects*: Equivalent to: return coroutine_handle<>::from_address(address());

View File

@@ -0,0 +1,15 @@
[coroutine.handle.noop.general]
# 17 Language support library [[support]](./#support)
## 17.13 Coroutines [[support.coroutine]](support.coroutine#coroutine.handle.noop.general)
### 17.13.5 No-op coroutines [[coroutine.noop]](coroutine.noop#coroutine.handle.noop.general)
#### 17.13.5.2 Class coroutine_handle<noop_coroutine_promise> [[coroutine.handle.noop]](coroutine.handle.noop#general)
#### 17.13.5.2.1 General [coroutine.handle.noop.general]
[🔗](#lib:coroutine_handle%3cnoop_coroutine_promise%3e)
namespace std {template<>struct coroutine_handle<noop_coroutine_promise>{// [[coroutine.handle.noop.conv]](coroutine.handle.noop.conv "17.13.5.2.2Conversion"), conversionconstexpr operator coroutine_handle<>() const noexcept; // [[coroutine.handle.noop.observers]](coroutine.handle.noop.observers "17.13.5.2.3Observers"), observersconstexpr explicit operator bool() const noexcept; constexpr bool done() const noexcept; // [[coroutine.handle.noop.resumption]](coroutine.handle.noop.resumption "17.13.5.2.4Resumption"), resumptionconstexpr void operator()() const noexcept; constexpr void resume() const noexcept; constexpr void destroy() const noexcept; // [[coroutine.handle.noop.promise]](coroutine.handle.noop.promise "17.13.5.2.5Promise access"), promise access noop_coroutine_promise& promise() const noexcept; // [[coroutine.handle.noop.address]](coroutine.handle.noop.address "17.13.5.2.6Address"), addressconstexpr void* address() const noexcept; private: coroutine_handle(*unspecified*); void* ptr; // *exposition only*};}

View File

@@ -0,0 +1,33 @@
[coroutine.handle.noop.observers]
# 17 Language support library [[support]](./#support)
## 17.13 Coroutines [[support.coroutine]](support.coroutine#coroutine.handle.noop.observers)
### 17.13.5 No-op coroutines [[coroutine.noop]](coroutine.noop#coroutine.handle.noop.observers)
#### 17.13.5.2 Class coroutine_handle<noop_coroutine_promise> [[coroutine.handle.noop]](coroutine.handle.noop#observers)
#### 17.13.5.2.3 Observers [coroutine.handle.noop.observers]
[🔗](#lib:operator_bool,coroutine_handle%3cnoop_coroutine_promise%3e)
`constexpr explicit operator bool() const noexcept;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6219)
*Returns*: true[.](#1.sentence-1)
[🔗](#lib:done,coroutine_handle%3cnoop_coroutine_promise%3e)
`constexpr bool done() const noexcept;
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6230)
*Returns*: false[.](#2.sentence-1)

View File

@@ -0,0 +1,23 @@
[coroutine.handle.noop.promise]
# 17 Language support library [[support]](./#support)
## 17.13 Coroutines [[support.coroutine]](support.coroutine#coroutine.handle.noop.promise)
### 17.13.5 No-op coroutines [[coroutine.noop]](coroutine.noop#coroutine.handle.noop.promise)
#### 17.13.5.2 Class coroutine_handle<noop_coroutine_promise> [[coroutine.handle.noop]](coroutine.handle.noop#promise)
#### 17.13.5.2.5 Promise access [coroutine.handle.noop.promise]
[🔗](#lib:promise,coroutine_handle%3cnoop_coroutine_promise%3e)
`noop_coroutine_promise& promise() const noexcept;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6266)
*Returns*: A reference to the promise object associated with this
coroutine handle[.](#1.sentence-1)

View File

@@ -0,0 +1,32 @@
[coroutine.handle.noop.resumption]
# 17 Language support library [[support]](./#support)
## 17.13 Coroutines [[support.coroutine]](support.coroutine#coroutine.handle.noop.resumption)
### 17.13.5 No-op coroutines [[coroutine.noop]](coroutine.noop#coroutine.handle.noop.resumption)
#### 17.13.5.2 Class coroutine_handle<noop_coroutine_promise> [[coroutine.handle.noop]](coroutine.handle.noop#resumption)
#### 17.13.5.2.4 Resumption [coroutine.handle.noop.resumption]
[🔗](#lib:operator(),coroutine_handle%3cnoop_coroutine_promise%3e)
`constexpr void operator()() const noexcept;
constexpr void resume() const noexcept;
constexpr void destroy() const noexcept;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6247)
*Effects*: None[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6251)
*Remarks*: If noop_coroutine_handle is converted to coroutine_handle<>,
calls to operator(), resume and destroy on that handle
will also have no observable effects[.](#2.sentence-1)

View File

@@ -0,0 +1,38 @@
[coroutine.handle.observers]
# 17 Language support library [[support]](./#support)
## 17.13 Coroutines [[support.coroutine]](support.coroutine#coroutine.handle.observers)
### 17.13.4 Class template coroutine_handle [[coroutine.handle]](coroutine.handle#observers)
#### 17.13.4.5 Observers [coroutine.handle.observers]
[🔗](#lib:operator_bool,coroutine_handle)
`constexpr explicit operator bool() const noexcept;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6021)
*Returns*: address() != nullptr[.](#1.sentence-1)
[🔗](#lib:done,coroutine_handle)
`bool done() const;
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6032)
*Preconditions*: *this refers to a suspended coroutine[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6036)
*Returns*: true if the coroutine is suspended at its
final suspend point, otherwise false[.](#3.sentence-1)

View File

@@ -0,0 +1,26 @@
[coroutine.handle.promise]
# 17 Language support library [[support]](./#support)
## 17.13 Coroutines [[support.coroutine]](support.coroutine#coroutine.handle.promise)
### 17.13.4 Class template coroutine_handle [[coroutine.handle]](coroutine.handle#promise)
#### 17.13.4.7 Promise access [coroutine.handle.promise]
[🔗](#lib:promise,coroutine_handle)
`Promise& promise() const;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6102)
*Preconditions*: *this refers to a coroutine[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6106)
*Returns*: A reference to the promise of the coroutine[.](#2.sentence-1)

View File

@@ -0,0 +1,71 @@
[coroutine.handle.resumption]
# 17 Language support library [[support]](./#support)
## 17.13 Coroutines [[support.coroutine]](support.coroutine#coroutine.handle.resumption)
### 17.13.4 Class template coroutine_handle [[coroutine.handle]](coroutine.handle#resumption)
#### 17.13.4.6 Resumption [coroutine.handle.resumption]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6044)
Resuming a coroutine via resume, operator(), or destroy on an execution agent other than the one on which it was suspended
has implementation-defined behavior
unless
each execution agent either is
an instance of std::thread or std::jthread,
or is the thread that executes main[.](#1.sentence-1)
[*Note [1](#note-1)*:
A coroutine that is resumed on a different execution agent should
avoid relying on consistent thread identity throughout, such as holding
a mutex object across a suspend point[.](#1.sentence-2)
— *end note*]
[*Note [2](#note-2)*:
A concurrent resumption of the coroutine can result in a data race[.](#1.sentence-3)
— *end note*]
[🔗](#lib:operator(),coroutine_handle)
`void operator()() const;
void resume() const;
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6069)
*Preconditions*: *this refers to a suspended coroutine[.](#2.sentence-1)
The coroutine is not suspended at its final suspend point[.](#2.sentence-2)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6074)
*Effects*: Resumes the execution of the coroutine[.](#3.sentence-1)
[🔗](#lib:destroy,coroutine_handle)
`void destroy() const;
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6085)
*Preconditions*: *this refers to a suspended coroutine[.](#4.sentence-1)
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6089)
*Effects*: Destroys the coroutine ([[dcl.fct.def.coroutine]](dcl.fct.def.coroutine "9.6.4Coroutine definitions"))[.](#5.sentence-1)

146
cppdraft/coroutine/noop.md Normal file
View File

@@ -0,0 +1,146 @@
[coroutine.noop]
# 17 Language support library [[support]](./#support)
## 17.13 Coroutines [[support.coroutine]](support.coroutine#coroutine.noop)
### 17.13.5 No-op coroutines [coroutine.noop]
#### [17.13.5.1](#coroutine.promise.noop) Class noop_coroutine_promise [[coroutine.promise.noop]](coroutine.promise.noop)
[🔗](#lib:noop_coroutine_promise)
`struct noop_coroutine_promise {};
`
[1](#coroutine.promise.noop-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6158)
The class noop_coroutine_promise defines the promise type for
the coroutine referred to
by noop_coroutine_handle ([[coroutine.syn]](coroutine.syn "17.13.2Header <coroutine> synopsis"))[.](#coroutine.promise.noop-1.sentence-1)
#### [17.13.5.2](#coroutine.handle.noop) Class coroutine_handle<noop_coroutine_promise> [[coroutine.handle.noop]](coroutine.handle.noop)
#### [17.13.5.2.1](#coroutine.handle.noop.general) General [[coroutine.handle.noop.general]](coroutine.handle.noop.general)
[🔗](#lib:coroutine_handle%3cnoop_coroutine_promise%3e)
namespace std {template<>struct coroutine_handle<noop_coroutine_promise>{// [[coroutine.handle.noop.conv]](#coroutine.handle.noop.conv "17.13.5.2.2Conversion"), conversionconstexpr operator coroutine_handle<>() const noexcept; // [[coroutine.handle.noop.observers]](#coroutine.handle.noop.observers "17.13.5.2.3Observers"), observersconstexpr explicit operator bool() const noexcept; constexpr bool done() const noexcept; // [[coroutine.handle.noop.resumption]](#coroutine.handle.noop.resumption "17.13.5.2.4Resumption"), resumptionconstexpr void operator()() const noexcept; constexpr void resume() const noexcept; constexpr void destroy() const noexcept; // [[coroutine.handle.noop.promise]](#coroutine.handle.noop.promise "17.13.5.2.5Promise access"), promise access noop_coroutine_promise& promise() const noexcept; // [[coroutine.handle.noop.address]](#coroutine.handle.noop.address "17.13.5.2.6Address"), addressconstexpr void* address() const noexcept; private: coroutine_handle(*unspecified*); void* ptr; // *exposition only*};}
#### [17.13.5.2.2](#coroutine.handle.noop.conv) Conversion [[coroutine.handle.noop.conv]](coroutine.handle.noop.conv)
[🔗](#lib:operator_coroutine_handle%3c%3e,coroutine_handle%3cnoop_coroutine_promise%3e)
`constexpr operator coroutine_handle<>() const noexcept;
`
[1](#coroutine.handle.noop.conv-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6206)
*Effects*: Equivalent to: return coroutine_handle<>::from_address(address());
#### [17.13.5.2.3](#coroutine.handle.noop.observers) Observers [[coroutine.handle.noop.observers]](coroutine.handle.noop.observers)
[🔗](#lib:operator_bool,coroutine_handle%3cnoop_coroutine_promise%3e)
`constexpr explicit operator bool() const noexcept;
`
[1](#coroutine.handle.noop.observers-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6219)
*Returns*: true[.](#coroutine.handle.noop.observers-1.sentence-1)
[🔗](#lib:done,coroutine_handle%3cnoop_coroutine_promise%3e)
`constexpr bool done() const noexcept;
`
[2](#coroutine.handle.noop.observers-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6230)
*Returns*: false[.](#coroutine.handle.noop.observers-2.sentence-1)
#### [17.13.5.2.4](#coroutine.handle.noop.resumption) Resumption [[coroutine.handle.noop.resumption]](coroutine.handle.noop.resumption)
[🔗](#lib:operator(),coroutine_handle%3cnoop_coroutine_promise%3e)
`constexpr void operator()() const noexcept;
constexpr void resume() const noexcept;
constexpr void destroy() const noexcept;
`
[1](#coroutine.handle.noop.resumption-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6247)
*Effects*: None[.](#coroutine.handle.noop.resumption-1.sentence-1)
[2](#coroutine.handle.noop.resumption-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6251)
*Remarks*: If noop_coroutine_handle is converted to coroutine_handle<>,
calls to operator(), resume and destroy on that handle
will also have no observable effects[.](#coroutine.handle.noop.resumption-2.sentence-1)
#### [17.13.5.2.5](#coroutine.handle.noop.promise) Promise access [[coroutine.handle.noop.promise]](coroutine.handle.noop.promise)
[🔗](#lib:promise,coroutine_handle%3cnoop_coroutine_promise%3e)
`noop_coroutine_promise& promise() const noexcept;
`
[1](#coroutine.handle.noop.promise-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6266)
*Returns*: A reference to the promise object associated with this
coroutine handle[.](#coroutine.handle.noop.promise-1.sentence-1)
#### [17.13.5.2.6](#coroutine.handle.noop.address) Address [[coroutine.handle.noop.address]](coroutine.handle.noop.address)
[🔗](#lib:address,coroutine_handle%3cnoop_coroutine_promise%3e)
`constexpr void* address() const noexcept;
`
[1](#coroutine.handle.noop.address-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6280)
*Returns*: ptr[.](#coroutine.handle.noop.address-1.sentence-1)
[2](#coroutine.handle.noop.address-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6284)
*Remarks*: A noop_coroutine_handle's ptr is always a
non-null pointer value[.](#coroutine.handle.noop.address-2.sentence-1)
#### [17.13.5.3](#coroutine) Function noop_coroutine [[coroutine.noop.coroutine]](coroutine.noop.coroutine)
[🔗](#lib:noop_coroutine)
`noop_coroutine_handle noop_coroutine() noexcept;
`
[1](#coroutine-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6298)
*Returns*: A handle to a coroutine that has no observable effects
when resumed or destroyed[.](#coroutine-1.sentence-1)
[2](#coroutine-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6303)
*Remarks*: A handle returned from noop_coroutine may or may not
compare equal to a handle returned from another invocation
of noop_coroutine[.](#coroutine-2.sentence-1)

View File

@@ -0,0 +1,29 @@
[coroutine.noop.coroutine]
# 17 Language support library [[support]](./#support)
## 17.13 Coroutines [[support.coroutine]](support.coroutine#coroutine.noop.coroutine)
### 17.13.5 No-op coroutines [[coroutine.noop]](coroutine.noop#coroutine)
#### 17.13.5.3 Function noop_coroutine [coroutine.noop.coroutine]
[🔗](#lib:noop_coroutine)
`noop_coroutine_handle noop_coroutine() noexcept;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6298)
*Returns*: A handle to a coroutine that has no observable effects
when resumed or destroyed[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6303)
*Remarks*: A handle returned from noop_coroutine may or may not
compare equal to a handle returned from another invocation
of noop_coroutine[.](#2.sentence-1)

View File

@@ -0,0 +1,22 @@
[coroutine.promise.noop]
# 17 Language support library [[support]](./#support)
## 17.13 Coroutines [[support.coroutine]](support.coroutine#coroutine.promise.noop)
### 17.13.5 No-op coroutines [[coroutine.noop]](coroutine.noop#coroutine.promise.noop)
#### 17.13.5.1 Class noop_coroutine_promise [coroutine.promise.noop]
[🔗](#lib:noop_coroutine_promise)
`struct noop_coroutine_promise {};
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6158)
The class noop_coroutine_promise defines the promise type for
the coroutine referred to
by noop_coroutine_handle ([[coroutine.syn]](coroutine.syn "17.13.2Header <coroutine> synopsis"))[.](#1.sentence-1)

13
cppdraft/coroutine/syn.md Normal file
View File

@@ -0,0 +1,13 @@
[coroutine.syn]
# 17 Language support library [[support]](./#support)
## 17.13 Coroutines [[support.coroutine]](support.coroutine#coroutine.syn)
### 17.13.2 Header <coroutine> synopsis [coroutine.syn]
[🔗](#header:%3ccoroutine%3e)
// all freestanding#include <compare> // see [[compare.syn]](compare.syn "17.12.1Header <compare> synopsis")namespace std {// [[coroutine.traits]](coroutine.traits "17.13.3Coroutine traits"), coroutine traitstemplate<class R, class... ArgTypes>struct coroutine_traits; // [[coroutine.handle]](coroutine.handle "17.13.4Class template coroutine_­handle"), coroutine handletemplate<class Promise = void>struct coroutine_handle; // [[coroutine.handle.compare]](coroutine.handle.compare "17.13.4.8Comparison operators"), comparison operatorsconstexpr bool operator==(coroutine_handle<> x, coroutine_handle<> y) noexcept; constexpr strong_ordering operator<=>(coroutine_handle<> x, coroutine_handle<> y) noexcept; // [[coroutine.handle.hash]](coroutine.handle.hash "17.13.4.9Hash support"), hash supporttemplate<class T> struct hash; template<class P> struct hash<coroutine_handle<P>>; // [[coroutine.noop]](coroutine.noop "17.13.5No-op coroutines"), no-op coroutinesstruct noop_coroutine_promise; template<> struct coroutine_handle<noop_coroutine_promise>; using noop_coroutine_handle = coroutine_handle<noop_coroutine_promise>;
noop_coroutine_handle noop_coroutine() noexcept; // [[coroutine.trivial.awaitables]](coroutine.trivial.awaitables "17.13.6Trivial awaitables"), trivial awaitablesstruct suspend_never; struct suspend_always;}

View File

@@ -0,0 +1,38 @@
[coroutine.traits]
# 17 Language support library [[support]](./#support)
## 17.13 Coroutines [[support.coroutine]](support.coroutine#coroutine.traits)
### 17.13.3 Coroutine traits [coroutine.traits]
#### [17.13.3.1](#general) General [[coroutine.traits.general]](coroutine.traits.general)
[1](#general-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L5798)
Subclause [coroutine.traits] defines requirements on classes representing[*coroutine traits*](#def:coroutine_traits),
and defines the class templatecoroutine_traits that meets those requirements[.](#general-1.sentence-1)
#### [17.13.3.2](#primary) Class template coroutine_traits [[coroutine.traits.primary]](coroutine.traits.primary)
[1](#primary-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L5808)
The header [<coroutine>](coroutine.syn#header:%3ccoroutine%3e "17.13.2Header <coroutine> synopsis[coroutine.syn]") defines the primary templatecoroutine_traits such that
if ArgTypes is a parameter pack of types and
if the [*qualified-id*](expr.prim.id.qual#nt:qualified-id "7.5.5.3Qualified names[expr.prim.id.qual]") R::promise_type is valid and
denotes a type ([[temp.deduct]](temp.deduct "13.10.3Template argument deduction")),
then coroutine_traits<R, ArgTypes...> has the following publicly
accessible member:using promise_type = typename R::promise_type;
Otherwise, coroutine_traits<R, ArgTypes...> has no members[.](#primary-1.sentence-2)
[2](#primary-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L5822)
Program-defined specializations of this template shall define a publicly
accessible nested type named promise_type[.](#primary-2.sentence-1)

View File

@@ -0,0 +1,16 @@
[coroutine.traits.general]
# 17 Language support library [[support]](./#support)
## 17.13 Coroutines [[support.coroutine]](support.coroutine#coroutine.traits.general)
### 17.13.3 Coroutine traits [[coroutine.traits]](coroutine.traits#general)
#### 17.13.3.1 General [coroutine.traits.general]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L5798)
Subclause [[coroutine.traits]](coroutine.traits "17.13.3Coroutine traits") defines requirements on classes representing[*coroutine traits*](#def:coroutine_traits),
and defines the class templatecoroutine_traits that meets those requirements[.](#1.sentence-1)

View File

@@ -0,0 +1,29 @@
[coroutine.traits.primary]
# 17 Language support library [[support]](./#support)
## 17.13 Coroutines [[support.coroutine]](support.coroutine#coroutine.traits.primary)
### 17.13.3 Coroutine traits [[coroutine.traits]](coroutine.traits#primary)
#### 17.13.3.2 Class template coroutine_traits [coroutine.traits.primary]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L5808)
The header [<coroutine>](coroutine.syn#header:%3ccoroutine%3e "17.13.2Header <coroutine> synopsis[coroutine.syn]") defines the primary templatecoroutine_traits such that
if ArgTypes is a parameter pack of types and
if the [*qualified-id*](expr.prim.id.qual#nt:qualified-id "7.5.5.3Qualified names[expr.prim.id.qual]") R::promise_type is valid and
denotes a type ([[temp.deduct]](temp.deduct "13.10.3Template argument deduction")),
then coroutine_traits<R, ArgTypes...> has the following publicly
accessible member:using promise_type = typename R::promise_type;
Otherwise, coroutine_traits<R, ArgTypes...> has no members[.](#1.sentence-2)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L5822)
Program-defined specializations of this template shall define a publicly
accessible nested type named promise_type[.](#2.sentence-1)

View File

@@ -0,0 +1,23 @@
[coroutine.trivial.awaitables]
# 17 Language support library [[support]](./#support)
## 17.13 Coroutines [[support.coroutine]](support.coroutine#coroutine.trivial.awaitables)
### 17.13.6 Trivial awaitables [coroutine.trivial.awaitables]
[🔗](#lib:suspend_never)
namespace std {struct suspend_never {constexpr bool await_ready() const noexcept { return true; }constexpr void await_suspend(coroutine_handle<>) const noexcept {}constexpr void await_resume() const noexcept {}}; struct suspend_always {constexpr bool await_ready() const noexcept { return false; }constexpr void await_suspend(coroutine_handle<>) const noexcept {}constexpr void await_resume() const noexcept {}};}
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6335)
[*Note [1](#note-1)*:
The types suspend_never and suspend_always can be used
to indicate that an [*await-expression*](expr.await#nt:await-expression "7.6.2.4Await[expr.await]") either never
suspends or always suspends, and in either case does not produce a value[.](#1.sentence-1)
— *end note*]