147 lines
6.2 KiB
Markdown
147 lines
6.2 KiB
Markdown
[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.2 Header <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.2 Conversion"), conversionconstexpr operator coroutine_handle<>() const noexcept; // [[coroutine.handle.noop.observers]](#coroutine.handle.noop.observers "17.13.5.2.3 Observers"), observersconstexpr explicit operator bool() const noexcept; constexpr bool done() const noexcept; // [[coroutine.handle.noop.resumption]](#coroutine.handle.noop.resumption "17.13.5.2.4 Resumption"), 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.5 Promise access"), promise access noop_coroutine_promise& promise() const noexcept; // [[coroutine.handle.noop.address]](#coroutine.handle.noop.address "17.13.5.2.6 Address"), 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)
|