File tree Expand file tree Collapse file tree 3 files changed +14
-10
lines changed Expand file tree Collapse file tree 3 files changed +14
-10
lines changed Original file line number Diff line number Diff line change 2174
2174
The optional \grammarterm {requires-clause}\iref {temp } in an
2175
2175
\grammarterm {init-declarator} or \grammarterm {member-declarator}
2176
2176
shall not be present when the declarator does not declare a
2177
- function\iref {dcl.fct }.
2177
+ templated function\iref {dcl.fct }.
2178
2178
%
2179
2179
\indextext {trailing requires-clause@trailing \textit {requires-clause }|see{\textit {requires-clause }, trailing}}%
2180
2180
When present after a declarator, the \grammarterm {requires-clause}
2187
2187
%
2188
2188
\begin {example }
2189
2189
\begin {codeblock }
2190
- void f1(int a) requires true; // OK
2191
- auto f2(int a) -> bool requires true; // OK
2192
- auto f3(int a) requires true -> bool; // error: \grammarterm {requires-clause} precedes \grammarterm {trailing-return-type}
2190
+ void f1(int a) requires true; // error: non-templated function
2191
+ template<typename T>
2192
+ auto f2(T a) -> bool requires true; // OK
2193
+ template<typename T>
2194
+ auto f3(T a) requires true -> bool; // error: \grammarterm {requires-clause} precedes \grammarterm {trailing-return-type}
2193
2195
void (*pf)() requires true; // error: constraint on a variable
2194
2196
void g(int (*)() requires true); // error: constraint on a \grammarterm {parameter-declaration}
2195
2197
Original file line number Diff line number Diff line change 1324
1324
is ill-formed.
1325
1325
\begin {example }
1326
1326
\begin {codeblock }
1327
- void f(int) requires false;
1327
+ template<typename T> struct A {
1328
+ static void f(int) requires false;
1329
+ }
1328
1330
1329
1331
void g() {
1330
- f(0); // error: cannot call \tcode {f}
1331
- void (*p1)(int) = f; // error: cannot take the address of \tcode {f}
1332
- decltype(f)* p2 = nullptr; // error: the type \tcode {decltype(f)} is invalid
1332
+ A<int>:: f(0); // error: cannot call \tcode {f}
1333
+ void (*p1)(int) = A<int>:: f; // error: cannot take the address of \tcode {f}
1334
+ decltype(A<int>:: f)* p2 = nullptr; // error: the type \tcode {decltype(A<int>:: f)} is invalid
1333
1335
}
1334
1336
\end {codeblock }
1335
1337
In each case, the constraints of \tcode {f} are not satisfied.
Original file line number Diff line number Diff line change 1647
1647
1648
1648
\pnum
1649
1649
A template declaration\iref {temp }
1650
- or function declaration\iref {dcl.fct }
1650
+ or templated function declaration\iref {dcl.fct }
1651
1651
can be constrained by the use of a \grammarterm {requires-clause}.
1652
1652
This allows the specification of constraints for that declaration as
1653
1653
an expression:
1666
1666
1667
1667
\pnum
1668
1668
\indextext {constraint!associated|see{associated constraints}}%
1669
- A template 's \defn {associated constraints} are defined as follows:
1669
+ A declaration 's \defn {associated constraints} are defined as follows:
1670
1670
1671
1671
\begin {itemize }
1672
1672
\item If there are no introduced \grammarterm {constraint-expression}{s},
You can’t perform that action at this time.
0 commit comments