Document Number: P0912R2
Date: 2018-06-08
Audience: WG21
Revises: P0912R1
Reply to: gorn@microsoft.com

Merge Coroutines TS into C++20 working draft

Abstract

This paper proposes merging Working Draft of Coroutines TS [N4736] into the C++20 working draft [N4741].

Revision history

r0: initial revision

r1:

r2:

Introduction

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.

Wording

Rationale: Required for new features. The requires keyword is added to introduce constraints through a requires-clause or a requires-expression. The concept keyword is added to enable the definition of concepts (17.6.8). The co_await, co_yield, and co_return keywords are added to enable the definition of coroutines (11.4.4). Effect on original feature: Valid ISO C++ 2017 code using concept, co_await, co_yield, co_return, or requires 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.

LWG requested edits on 2018-June-08

The header <experimental/coroutine> defines the primary template coroutine_traits such that if ArgTypes is a parameter pack of types and if R is a type that has a valid (17.8.2) member type promise_type, if the qualified-id R::promise_type is valid and denotes a type (17.9.2), then coroutine_traits<R,ArgTypes...> has the following publicly accessible member:
AllProgram defined specializations of this template shall define a publicly accessible nested type named promise_type.
Returns: true if address() != 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()).
Remarks: A noop_coroutine_handle’s ptr is always contains a non-null pointer value.
struct noop_coroutine_promise {};