Skip to content

Commit bc68ff5

Browse files
authored
Merge 2019-11 CWG Motion 10
P1980R0 CA096: Declaration matching for non-dependent requires-clauses
2 parents 5a70ebf + 80063df commit bc68ff5

File tree

3 files changed

+73
-38
lines changed

3 files changed

+73
-38
lines changed

source/expressions.tex

Lines changed: 8 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,8 @@
416416
\ref{expr.sizeof},
417417
\ref{expr.unary.noexcept},
418418
\ref{dcl.type.simple},
419-
\ref{temp}).
419+
\ref{temp.pre},
420+
\ref{temp.concept}).
420421
An unevaluated operand is not evaluated.
421422
\begin{note}
422423
In an unevaluated operand, a non-static class member may be
@@ -1285,30 +1286,6 @@
12851286
\item in an immediate function context\iref{expr.const}.
12861287
\end{itemize}
12871288

1288-
\pnum
1289-
An \grammarterm{id-expression}
1290-
that denotes the specialization of a concept\iref{temp.concept}
1291-
results in a prvalue of type \tcode{bool}.
1292-
The expression is \tcode{true} if
1293-
the concept's normalized
1294-
\grammarterm{constraint-expression}\iref{temp.constr.decl}
1295-
is satisfied\iref{temp.constr.constr}
1296-
by the specified template arguments
1297-
and \tcode{false} otherwise.
1298-
\begin{example}
1299-
\begin{codeblock}
1300-
template<typename T> concept C = true;
1301-
static_assert(C<int>); // OK
1302-
\end{codeblock}
1303-
\end{example}
1304-
\begin{note}
1305-
A concept's constraints are also considered
1306-
when using a template name\iref{temp.names}
1307-
and during overload resolution\iref{over},
1308-
and they are compared
1309-
during the partial ordering of constraints\iref{temp.constr.order}.
1310-
\end{note}
1311-
13121289
\pnum
13131290
For an \grammarterm{id-expression} that denotes an overload set,
13141291
overload resolution is performed
@@ -7330,9 +7307,6 @@
73307307
if it is an explicit or implicit invocation of an immediate function and
73317308
is not in an immediate function context.
73327309
An immediate invocation shall be a constant expression.
7333-
\begin{note}
7334-
An immediate invocation is evaluated even in an unevaluated operand.
7335-
\end{note}
73367310

73377311
\pnum
73387312
An expression or conversion \tcode{e} is \defn{manifestly constant-evaluated}
@@ -7341,9 +7315,8 @@
73417315
\item a \grammarterm{constant-expression}, or
73427316
\item the condition of a constexpr if statement\iref{stmt.if}, or
73437317
\item an immediate invocation, or
7344-
\item a \grammarterm{constraint-expression}\iref{temp.constr.decl}
7345-
including one formed from the \grammarterm{constraint-logical-or-expression}
7346-
of a \grammarterm{requires-clause}, or
7318+
\item the result of substitution into an atomic constraint expression
7319+
to determine whether it is satisfied\iref{temp.constr.atomic}, or
73477320
\item the initializer of a variable
73487321
that is usable in constant expressions or
73497322
has constant initialization.\footnote{Testing this condition
@@ -7370,6 +7343,10 @@
73707343
\end{codeblock}
73717344
\end{example}
73727345
\end{itemize}
7346+
\begin{note}
7347+
A manifestly constant-evaluated expression
7348+
is evaluated even in an unevaluated operand.
7349+
\end{note}
73737350

73747351
\pnum
73757352
\indextext{expression!potentially constant evaluated}%

source/overloading.tex

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,20 @@
325325
\pnum
326326
Two function declarations of the same name refer to the same function if they
327327
are in the same scope and have equivalent parameter declarations\iref{over.load}
328-
and equivalent trailing \grammarterm{requires-clause}{s}, if any\iref{dcl.decl}.
328+
and equivalent\iref{temp.over.link} trailing \grammarterm{requires-clause}{s}, if any\iref{dcl.decl}.
329+
\begin{note}
330+
Since a \grammarterm{constraint-expression} is an unevaluated operand,
331+
equivalence compares the expressions without evaluating them.
332+
\begin{example}
333+
\begin{codeblock}
334+
template<int I> concept C = true;
335+
template<typename T> struct A {
336+
void f() requires C<42>; // \#1
337+
void f() requires true; // OK, different functions
338+
};
339+
\end{codeblock}
340+
\end{example}
341+
\end{note}
329342
A function member of a derived class is
330343
\textit{not}
331344
in the same scope as a function member of the same name in a base class.

source/templates.tex

Lines changed: 51 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@
226226
the \grammarterm{constraint-logical-or-expression} as a
227227
\grammarterm{constraint-expression}.
228228
The \grammarterm{constraint-logical-or-expression} of a
229-
\grammarterm{requires-clause} is an unevaluated operand\iref{expr}.
229+
\grammarterm{requires-clause} is an unevaluated operand\iref{expr.context}.
230230
\begin{note}
231231
The expression in a \grammarterm{requires-clause}
232232
uses a restricted grammar to avoid ambiguities.
@@ -940,6 +940,29 @@
940940
\end{codeblock}
941941
\end{example}
942942

943+
\pnum
944+
A \defn{concept-id} is a \grammarterm{simple-template-id}
945+
where the \grammarterm{template-name} is a \grammarterm{concept-name}.
946+
A concept-id is a prvalue of type \tcode{bool}, and
947+
does not name a template specialization.
948+
A concept-id evaluates to \tcode{true}
949+
if the concept's
950+
normalized \grammarterm{constraint-expression}\iref{temp.constr.decl}
951+
is satisfied\iref{temp.constr.constr} by the specified template arguments and
952+
\tcode{false} otherwise.
953+
\begin{note}
954+
Since a \grammarterm{constraint-expression} is an unevaluated operand,
955+
a concept-id appearing in a \grammarterm{constraint-expression}
956+
is not evaluated except as necessary
957+
to determine whether the normalized constraints are satisfied.
958+
\end{note}
959+
\begin{example}
960+
\begin{codeblock}
961+
template<typename T> concept C = true;
962+
static_assert(C<int>); // OK
963+
\end{codeblock}
964+
\end{example}
965+
943966
\rSec1[temp.arg]{Template arguments}
944967

945968
\pnum
@@ -1754,8 +1777,7 @@
17541777
the normal forms of \tcode{E1} and \tcode{E2}.
17551778

17561779
\item
1757-
The normal form of an \grammarterm{id-expression} of the form
1758-
\tcode{C<A$_1$, A$_2$, ..., A$_n$>}, where \tcode{C} names a concept,
1780+
The normal form of a concept-id \tcode{C<A$_1$, A$_2$, ..., A$_n$>}
17591781
is the normal form of the \grammarterm{constraint-expression} of \tcode{C},
17601782
after substituting \tcode{A$_1$, A$_2$, ..., A$_n$} for
17611783
\tcode{C}{'s} respective template parameters in the
@@ -3556,6 +3578,19 @@
35563578
to name the template parameters may differ as long as a token used to
35573579
name a template parameter in one expression is replaced by another token
35583580
that names the same template parameter in the other expression.
3581+
Two unevaluated operands that do not involve template parameters
3582+
are considered equivalent
3583+
if two function definitions containing the expressions
3584+
would satisfy the one-definition rule,
3585+
except that the tokens used to name types and declarations may differ
3586+
as long as they name the same entities, and
3587+
the tokens used to form concept-ids may differ
3588+
as long as the two \grammarterm{template-id}{s}
3589+
would be considered to name the same type if,
3590+
instead of a concept, a class template were named.
3591+
\begin{note}
3592+
For instance, \tcode{A<42>} and \tcode{A<40+2>} name the same type.
3593+
\end{note}
35593594
Two \grammarterm{lambda-expression}{s} are never considered equivalent.
35603595
\begin{note}
35613596
The intent is to avoid \grammarterm{lambda-expression}{s} appearing in the
@@ -3588,10 +3623,17 @@
35883623
\end{codeblock}
35893624
\end{example}
35903625
\indextext{expression!functionally equivalent|see{functionally equivalent, expressions}}%
3591-
Two expressions involving template parameters that are not equivalent are
3626+
Two potentially-evaluated expressions involving template parameters that are not equivalent are
35923627
\defnx{functionally equivalent}{functionally equivalent!expressions}
35933628
if, for any given set of template arguments, the evaluation of the
35943629
expression results in the same value.
3630+
Two unevaluated operands that are not equivalent
3631+
are functionally equivalent if, for any given set of template arguments,
3632+
the expressions perform
3633+
the same operations in the same order with the same entities.
3634+
\begin{note}
3635+
For instance, one could have redundant parentheses.
3636+
\end{note}
35953637

35963638
\pnum
35973639
Two \grammarterm{template-head}{s} are
@@ -3972,14 +4014,17 @@
39724014
\pnum
39734015
A concept is not instantiated\iref{temp.spec}.
39744016
\begin{note}
3975-
An \grammarterm{id-expression} that denotes a concept specialization
3976-
is evaluated as an expression\iref{expr.prim.id}.
4017+
A concept-id\iref{temp.names} is evaluated as an expression.
39774018
A concept cannot be
39784019
explicitly instantiated\iref{temp.explicit},
39794020
explicitly specialized\iref{temp.expl.spec},
39804021
or partially specialized.
39814022
\end{note}
39824023

4024+
\pnum
4025+
The \grammarterm{constraint-expression} of a \grammarterm{concept-definition}
4026+
is an unevaluated operand\iref{expr.context}.
4027+
39834028
\pnum
39844029
The first declared template parameter of a concept definition is its
39854030
\defnx{prototype parameter}{prototype parameter!concept}.

0 commit comments

Comments
 (0)