requires-clause syntax ambiguities: wording to apply custom grammar

Document number: P0730R1
Date: 2017-07-12
Project: ISO/IEC JTC 1/SC 22/WG 21/C++
Working Group: Core
Revises: P0730R0
Reply-to: Hubert S.K. Tong <hubert.reinterpretcast@gmail.com>

What’s New

The previous revision of the paper, P0730R0, was discussed in EWG on Tuesday of the 2017 Toronto meeting of WG 21. Direction was given to pursue the custom grammar solution with wording to present to Core. This paper, P0730R1, is the wording paper.

Background and Context for This Paper

Prior to the discussion of P0730R0 in EWG, direction was given in response to P0716R0, which removes function concepts. The wording presented herein is contingent upon adopting wording that implements the removal of function concepts.

Wording

The editing instructions within this document use, as its base wording, the result of applying the TS working draft (N4674) to an appropriate base document.

In Clause 17 [temp] paragraph 1, modify:

template-declaration:
template < template-parameter-list > requires-clauseopt declaration
template-introduction declaration
requires-clause:
requires constraint-expression
template-parameter-list:
template-parameter
template-parameter-list , template-parameter
requires-clause:
requires constraint-logical-or-expression
constraint-logical-and-expression:
primary-expression
constraint-logical-and-expression && primary-expression
constraint-logical-or-expression:
constraint-logical-and-expression
constraint-logical-or-expression || constraint-logical-and-expression

At the beginning of subclause 8.1.7.4 [expr.prim.req.nested], modify:

nested-requirement:
requires-clauserequires constraint-expression ;

In subclause 17.10.2 [temp.constr.decl] paragraph 2, modify bullet 2.3.5:

In subclause 17.10.1.2 [temp.constr.pred] paragraph 1, modify the note:

[ … ] [ Note: A predicate constraint is introduced by the constraint-expression of a requires-clause (17.10.2), or as the associated constraint of a constrained-parameter (17.1) or template-introduction (17.2). —end note ] [ … ]

In Clause 17 [temp] paragraph 7, modify:

A template-declaration is written in terms of its template parameters. These parameters are declared explicitly in a template-parameter-list (17.1), or they are introduced by a template-introduction (17.2). The optional requires-clause following a template-parameter-list allows the specification of constraints (17.10.2) on template arguments (17.4). The requires-clause introduces the constraint-expression that results from interpreting the constraint-logical-or-expression as a constraint-expression.

Acknowledgements

The author would like to thank Ville Voutilainen and Richard Smith for their input in discussions leading up to the production of P0730R0. As usual, any mistakes are the responsibility of the author.