Skip to content

Commit bddd47c

Browse files
jensmaurerzygoloid
authored andcommitted
[temp.param] Move grammar non-terminal 'type-constraint' here
from [temp.pre]. Also move the definition of 'immediately-declared constraint' and fix all cross-references.
1 parent 8d288c1 commit bddd47c

File tree

3 files changed

+43
-43
lines changed

3 files changed

+43
-43
lines changed

source/declarations.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2009,7 +2009,7 @@
20092009
\pnum
20102010
For a \grammarterm{placeholder-type-specifier}
20112011
with a \grammarterm{type-constraint},
2012-
the immediately-declared constraint\iref{temp.pre}
2012+
the immediately-declared constraint\iref{temp.param}
20132013
of the \grammarterm{type-constraint} for the type deduced for the placeholder
20142014
shall be satisfied.
20152015

source/expressions.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2685,7 +2685,7 @@
26852685
into the \grammarterm{return-type-requirement} is performed.
26862686

26872687
\item
2688-
The immediately-declared constraint\iref{temp.pre}
2688+
The immediately-declared constraint\iref{temp.param}
26892689
of the \grammarterm{type-constraint} for \tcode{decltype((E))}
26902690
shall be satisfied.
26912691
\begin{example}

source/templates.tex

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,6 @@
4949
constraint-logical-and-expression \terminal{\&\&} primary-expression
5050
\end{bnf}
5151

52-
\begin{bnf}
53-
\nontermdef{type-constraint}\br
54-
\opt{nested-name-specifier} concept-name\br
55-
\opt{nested-name-specifier} concept-name \terminal{<} \opt{template-argument-list} \terminal{>}
56-
\end{bnf}
57-
5852
\begin{note}
5953
The \tcode{>} token following the
6054
\grammarterm{template-parameter-list} of a
@@ -141,23 +135,6 @@
141135
When such a declaration is used to declare a class template,
142136
no declarator is permitted.
143137

144-
\pnum
145-
A \grammarterm{type-constraint} \tcode{Q} that designates a concept \tcode{C}
146-
can be used to constrain a
147-
contextually-determined type or template type parameter pack \tcode{T}
148-
with a \grammarterm{constraint-expression} \tcode{E} defined as follows.
149-
If \tcode{Q} is of the form \tcode{C<A$_1$, $\cdots$, A$_n$>},
150-
then let \tcode{E$'$} be \tcode{C<T, A$_1$, $\cdots$, A$_n$>}.
151-
Otherwise, let \tcode{E$'$} be \tcode{C<T>}.
152-
If \tcode{T} is not a pack,
153-
then \tcode{E} is \tcode{E$'$},
154-
otherwise \tcode{E} is \tcode{(E$'$ \&\& ...)}.
155-
This \grammarterm{constraint-expression} \tcode{E} is called the
156-
\defnx{immediately-declared constraint}{constraint!immediately-declared}
157-
of \tcode{Q} for \tcode{T}.
158-
The concept designated by a \grammarterm{type-constraint}
159-
shall be a type concept\iref{temp.concept}.
160-
161138
\pnum
162139
\indextext{template name!linkage of}%
163140
A template name has linkage\iref{basic.link}.
@@ -267,6 +244,12 @@
267244
\keyword{typename}
268245
\end{bnf}
269246

247+
\begin{bnf}
248+
\nontermdef{type-constraint}\br
249+
\opt{nested-name-specifier} concept-name\br
250+
\opt{nested-name-specifier} concept-name \terminal{<} \opt{template-argument-list} \terminal{>}
251+
\end{bnf}
252+
270253
\begin{note}
271254
The \tcode{>} token following the
272255
\grammarterm{template-parameter-list} of a
@@ -353,6 +336,41 @@
353336
\end{codeblock}
354337
\end{note}
355338

339+
\pnum
340+
A \grammarterm{type-constraint} \tcode{Q} that designates a concept \tcode{C}
341+
can be used to constrain a
342+
contextually-determined type or template type parameter pack \tcode{T}
343+
with a \grammarterm{constraint-expression} \tcode{E} defined as follows.
344+
If \tcode{Q} is of the form \tcode{C<A$_1$, $\cdots$, A$_n$>},
345+
then let \tcode{E$'$} be \tcode{C<T, A$_1$, $\cdots$, A$_n$>}.
346+
Otherwise, let \tcode{E$'$} be \tcode{C<T>}.
347+
If \tcode{T} is not a pack,
348+
then \tcode{E} is \tcode{E$'$},
349+
otherwise \tcode{E} is \tcode{(E$'$ \&\& ...)}.
350+
This \grammarterm{constraint-expression} \tcode{E} is called the
351+
\defnx{immediately-declared constraint}{constraint!immediately-declared}
352+
of \tcode{Q} for \tcode{T}.
353+
The concept designated by a \grammarterm{type-constraint}
354+
shall be a type concept\iref{temp.concept}.
355+
356+
\pnum
357+
A \grammarterm{type-parameter} that starts with a \grammarterm{type-constraint}
358+
introduces the immediately-declared constraint
359+
of the \grammarterm{type-constraint} for the parameter.
360+
\begin{example}
361+
\begin{codeblock}
362+
template<typename T> concept C1 = true;
363+
template<typename... Ts> concept C2 = true;
364+
template<typename T, typename U> concept C3 = true;
365+
366+
template<C1 T> struct s1; // associates \tcode{C1<T>}
367+
template<C1... T> struct s2; // associates \tcode{(C1<T> \&\& ...)}
368+
template<C2... T> struct s3; // associates \tcode{(C2<T> \&\& ...)}
369+
template<C3<int> T> struct s4; // associates \tcode{C3<T, int>}
370+
template<C3<int>... T> struct s5; // associates \tcode{(C3<T, int> \&\& ...)}
371+
\end{codeblock}
372+
\end{example}
373+
356374
\pnum
357375
A non-type \grammarterm{template-parameter}
358376
shall have one of the following (optionally cv-qualified) types:
@@ -451,24 +469,6 @@
451469
\end{codeblock}
452470
\end{example}
453471

454-
\pnum
455-
A \grammarterm{type-parameter} that starts with a \grammarterm{type-constraint}
456-
introduces the immediately-declared constraint\iref{temp.pre}
457-
of the \grammarterm{type-constraint} for the parameter.
458-
\begin{example}
459-
\begin{codeblock}
460-
template<typename T> concept C1 = true;
461-
template<typename... Ts> concept C2 = true;
462-
template<typename T, typename U> concept C3 = true;
463-
464-
template<C1 T> struct s1; // associates \tcode{C1<T>}
465-
template<C1... T> struct s2; // associates \tcode{(C1<T> \&\& ...)}
466-
template<C2... T> struct s3; // associates \tcode{(C2<T> \&\& ...)}
467-
template<C3<int> T> struct s4; // associates \tcode{C3<T, int>}
468-
template<C3<int>... T> struct s5; // associates \tcode{(C3<T, int> \&\& ...)}
469-
\end{codeblock}
470-
\end{example}
471-
472472
\pnum
473473
A non-type template parameter declared with a type that
474474
contains a placeholder type with a \grammarterm{type-constraint}

0 commit comments

Comments
 (0)