Document Number: | P0912R2 |
---|---|
Date: | 2018-06-08 |
Audience: | WG21 |
Revises: | P0912R1 |
Reply to: | gorn@microsoft.com |
This paper proposes merging Working Draft of Coroutines TS [N4736] into the C++20 working draft [N4741].
r0: initial revision
r1:
r2:
Coroutines address the dire need by dramatically simplifying development of asynchronous code. Coroutines have been available and in use for 4 years. We have implementations from two major compiler vendors. It is time to merge Coroutines TS to the working paper.
Apply coroutine wording from N4736 to the working draft with the following changes:
experimental::
with nothing<experimental/coroutine>
with <coroutine>
Apply changes from "LWG requested edits on 2018-June-08" section below.
Apply resolution of issue 29 from Coroutine TS issue list P0664R4.
Add underlined text to rationale in [diff.cpp17.lex]:
Rationale: Required for new features. The
requires
keyword is added to introduce constraints through a requires-clause or a requires-expression. Theconcept
keyword is added to enable the definition of concepts (17.6.8). Theco_await
,co_yield
, andco_return
keywords are added to enable the definition of coroutines (11.4.4). Effect on original feature: Valid ISO C++ 2017 code usingconcept
,co_await
,co_yield
,co_return
, orrequires
as an identifier is not valid in this International Standard.
Effect on original feature: The following C++ headers are new:
<compare>
,<coroutine>
, and<syncstream>
. Valid C++ 2017 code that #includes headers with these names may be invalid in this International Standard.
The header<experimental/coroutine>
defines the primary template coroutine_traits such that ifArgTypes
is a parameter pack of types andifif the qualified-idR
is a type that has a valid (17.8.2) member typepromise_type
,R::promise_type
is valid and denotes a type (17.9.2), thencoroutine_traits<R,ArgTypes...>
has the following publicly accessible member:
AllProgram defined specializations of this template shall define a publicly accessible nested type namedpromise_type
.
In clause 21.11 in titles of the subclauses replace "Struct template" with "Class template"
In clause 21.11 template introducers replace "typename" with "class"
Modify the paragraph 3 in subclause 21.11.2.3/[coroutine.handle.observers] as follows:
Returns:true ifaddress() != nullptr
, otherwise false.
Synchronization: a[Note: A concurrent resumption of the coroutine via resume, operator(), or destroy may result in a data race.--endnote]
Returns: less<void*>()(x.address(), y.address())
.
Reorder relational operators in synopsis 21.11/[support.coroutine] and in subclause 21.11.2.6/[coroutine.handle.compare] to be in the following order: ==, !=, <, >, <=, >=
.
Modify 21.11.2.11/[coroutine.handle.noop.address] as follows:
Remarks: A noop_coroutine_handle’s ptr is alwayscontainsa non-null pointer value.
struct noop_coroutine_promise {};