Skip to content

Commit b0bc378

Browse files
committed
Merge 2017-07 CWG Motion 11
2 parents 2023c5a + 02574b8 commit b0bc378

File tree

11 files changed

+1650
-123
lines changed

11 files changed

+1650
-123
lines changed

source/basic.tex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,7 @@
427427
with external linkage~(\ref{dcl.inline}), inline variable with external
428428
linkage~(\ref{dcl.inline}), class template
429429
(Clause~\ref{temp}), non-static function template~(\ref{temp.fct}),
430+
concept (\ref{temp.concept}),
430431
static data member of a class template~(\ref{temp.static}), member
431432
function of a class template~(\ref{temp.mem.func}), or template
432433
specialization for which some template parameters are not

source/classes.tex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,7 @@
466466
\begin{bnf}
467467
\nontermdef{member-declarator}\br
468468
declarator virt-specifier-seq\opt pure-specifier\opt\br
469+
declarator requires-clause\br
469470
declarator brace-or-equal-initializer\opt\br
470471
identifier\opt{} attribute-specifier-seq\opt{} \terminal{:} constant-expression brace-or-equal-initializer\opt{}
471472
\end{bnf}

source/compatibility.tex

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1802,6 +1802,27 @@
18021802
\effect A valid \CppXIV program using these identifiers
18031803
may be ill-formed in this International Standard.
18041804

1805+
\rSec1[diff.cpp17]{\Cpp and ISO \CppXVII}
1806+
1807+
\pnum
1808+
\indextext{summary!compatibility with ISO \CppXVII}%
1809+
This subclause lists the differences between \Cpp and
1810+
ISO \CppXVII (ISO/IEC 14882:2017, \doccite{Programming Languages --- \Cpp}),
1811+
by the chapters of this document.
1812+
1813+
\rSec2[diff.cpp17.lex]{Clause~\ref{lex}: lexical conventions}
1814+
1815+
\ref{lex.key}
1816+
\change New keywords.\\
1817+
\rationale Required for new features.
1818+
The \tcode{requires} keyword is added
1819+
to introduce constraints through a \grammarterm{requires-clause} or
1820+
a \grammarterm{requires-expression}. The \tcode{concept} keyword is
1821+
added to enable the definition of concepts (\ref{temp.concept}).
1822+
\effect
1823+
Valid ISO \CppXVII code using \tcode{concept} or \tcode{requires}
1824+
as an identifier is not valid in this International Standard.
1825+
18051826
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
18061827
\rSec1[diff.library]{C standard library}
18071828
\indextext{library!C standard}%

source/declarators.tex

Lines changed: 38 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727

2828
\begin{bnf}
2929
\nontermdef{init-declarator}\br
30-
declarator initializer\opt
30+
declarator initializer\opt\br
31+
declarator requires-clause
3132
\end{bnf}
3233

3334
\pnum
@@ -95,6 +96,32 @@
9596
\end{codeblock}
9697
\end{note}
9798

99+
\pnum
100+
The optional \grammarterm{requires-clause} (Clause~\ref{temp}) in an
101+
\grammarterm{init-declarator} or \grammarterm{member-declarator}
102+
shall not be present when the declarator does not declare a
103+
function (\ref{dcl.fct}).
104+
%
105+
When present after a declarator, the \grammarterm{requires-clause}
106+
is called the \defnx{trailing \grammarterm{requires-clause}{}}{%
107+
trailing requires-clause@trailing \grammarterm{requires-clause}}.
108+
The trailing \grammarterm{requires-clause} introduces the
109+
\grammarterm{constraint-expression} that results from interpreting
110+
its \grammarterm{constraint-logical-or-expression} as a
111+
\grammarterm{constraint-expression}.
112+
%
113+
\begin{example}
114+
\begin{codeblock}
115+
void f1(int a) requires true; // OK
116+
auto f2(int a) -> bool requires true; // OK
117+
auto f3(int a) requires true -> bool; // error: \grammarterm{requires-clause} precedes \grammarterm{trailing-return-type}
118+
void (*pf)() requires true; // error: constraint on a variable
119+
void g(int (*)() requires true); // error: constraint on a \grammarterm{parameter-declaration}
120+
121+
auto* p = new void(*)(char) requires true; // error: not a function declaration
122+
\end{codeblock}
123+
\end{example}
124+
98125
\pnum
99126
Declarators have the syntax
100127

@@ -1403,8 +1430,8 @@
14031430
\indextext{type!function}%
14041431
A single name can be used for several different functions in a single scope;
14051432
this is function overloading (Clause~\ref{over}).
1406-
All declarations for a function shall agree exactly
1407-
in both the return type and the parameter-type-list.
1433+
All declarations for a function shall have equivalent return types,
1434+
parameter-type-lists, and \grammarterm{requires-clause}{s} (\ref{temp.over.link}).
14081435
The type of a function is determined using the following rules.
14091436
The type of each parameter (including function parameter packs) is
14101437
determined from its own
@@ -1483,7 +1510,8 @@
14831510
The return type, the parameter-type-list, the \grammarterm{ref-qualifier},
14841511
the \grammarterm{cv-qualifier-seq}, and
14851512
the exception specification,
1486-
but not the default arguments~(\ref{dcl.fct.default}),
1513+
but not the default arguments~(\ref{dcl.fct.default})
1514+
or \grammarterm{requires-clause}{s}~(Clause~\ref{temp}),
14871515
are part of the function type.
14881516
\begin{note}
14891517
Function types are checked during the assignments and initializations of
@@ -1990,7 +2018,8 @@
19902018
%
19912019
\begin{bnf}
19922020
\nontermdef{function-definition}\br
1993-
attribute-specifier-seq\opt decl-specifier-seq\opt declarator virt-specifier-seq\opt function-body
2021+
attribute-specifier-seq\opt decl-specifier-seq\opt declarator virt-specifier-seq\opt function-body\br
2022+
attribute-specifier-seq\opt decl-specifier-seq\opt declarator requires-clause function-body
19942023
\end{bnf}
19952024

19962025
\begin{bnf}
@@ -2104,12 +2133,8 @@
21042133
\indextext{definition!function!explicitly-defaulted}%
21052134

21062135
\pnum
2107-
A function definition of the form:
2108-
2109-
\begin{ncbnf}
2110-
attribute-specifier-seq\opt decl-specifier-seq\opt declarator virt-specifier-seq\opt{} \terminal{ = default ;}
2111-
\end{ncbnf}
2112-
2136+
A function definition
2137+
with the \grammarterm{function-body} \tcode{= default ;}
21132138
is called an \grammarterm{explicitly-defaulted} definition.
21142139
A function that is explicitly defaulted shall
21152140

@@ -2202,12 +2227,8 @@
22022227
\indextext{definition!function!deleted}%
22032228

22042229
\pnum
2205-
A function definition of the form:
2206-
2207-
\begin{ncbnf}
2208-
attribute-specifier-seq\opt decl-specifier-seq\opt declarator virt-specifier-seq\opt{} \terminal{ = delete ;}
2209-
\end{ncbnf}
2210-
2230+
A function definition
2231+
with the \grammarterm{function-body} \tcode{= delete ;}
22112232
is called a \term{deleted definition}. A function with a
22122233
deleted definition is also called a \term{deleted function}.
22132234

source/derived.tex

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,16 @@
690690
\end{codeblock}
691691
\end{example}
692692

693+
\pnum
694+
A virtual function shall not have a \grammarterm{requires-clause}.
695+
\begin{example}
696+
\begin{codeblock}
697+
struct A {
698+
virtual void f() requires true; // error: constrained virtual function
699+
};
700+
\end{codeblock}
701+
\end{example}
702+
693703
\pnum
694704
Even though destructors are not inherited, a destructor in a derived
695705
class overrides a base class destructor declared virtual;

0 commit comments

Comments
 (0)