From Jason Turner

[expr.prim.req.nested]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp6um98ouk/{from.md → to.md} +43 -0
tmp/tmp6um98ouk/{from.md → to.md} RENAMED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #### Nested requirements <a id="expr.prim.req.nested">[[expr.prim.req.nested]]</a>
2
+
3
+ ``` bnf
4
+ nested-requirement:
5
+ requires constraint-expression ';'
6
+ ```
7
+
8
+ A *nested-requirement* can be used to specify additional constraints in
9
+ terms of local parameters. The *constraint-expression* shall be
10
+ satisfied [[temp.constr.decl]] by the substituted template arguments, if
11
+ any. Substitution of template arguments into a *nested-requirement* does
12
+ not result in substitution into the *constraint-expression* other than
13
+ as specified in [[temp.constr.constr]].
14
+
15
+ [*Example 1*:
16
+
17
+ ``` cpp
18
+ template<typename U> concept C = sizeof(U) == 1;
19
+
20
+ template<typename T> concept D = requires (T t) {
21
+ requires C<decltype (+t)>;
22
+ };
23
+ ```
24
+
25
+ `D<T>` is satisfied if `sizeof(decltype (+t)) == 1`
26
+ [[temp.constr.atomic]].
27
+
28
+ — *end example*]
29
+
30
+ A local parameter shall only appear as an unevaluated operand
31
+ [[expr.prop]] within the *constraint-expression*.
32
+
33
+ [*Example 2*:
34
+
35
+ ``` cpp
36
+ template<typename T> concept C = requires (T a) {
37
+ requires sizeof(a) == 4; // OK
38
+ requires a == 0; // error: evaluation of a constraint variable
39
+ };
40
+ ```
41
+
42
+ — *end example*]
43
+