From Jason Turner

[expr.prim.req.compound]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp1hbglop1/{from.md → to.md} +78 -0
tmp/tmp1hbglop1/{from.md → to.md} RENAMED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #### Compound requirements <a id="expr.prim.req.compound">[[expr.prim.req.compound]]</a>
2
+
3
+ ``` bnf
4
+ compound-requirement:
5
+ '{' expression '}' noexceptₒₚₜ return-type-requirementₒₚₜ ';'
6
+ ```
7
+
8
+ ``` bnf
9
+ return-type-requirement:
10
+ '->' type-constraint
11
+ ```
12
+
13
+ A *compound-requirement* asserts properties of the *expression* E.
14
+ Substitution of template arguments (if any) and verification of semantic
15
+ properties proceed in the following order:
16
+
17
+ - Substitution of template arguments (if any) into the *expression* is
18
+ performed.
19
+ - If the `noexcept` specifier is present, E shall not be a
20
+ potentially-throwing expression [[except.spec]].
21
+ - If the *return-type-requirement* is present, then:
22
+ - Substitution of template arguments (if any) into the
23
+ *return-type-requirement* is performed.
24
+ - The immediately-declared constraint [[temp.param]] of the
25
+ *type-constraint* for `decltype((E))` shall be satisfied.
26
+ \[*Example 1*:
27
+ Given concepts `C` and `D`,
28
+ ``` cpp
29
+ requires {
30
+ { E1 } -> C;
31
+ { E2 } -> D<A₁, ⋯, Aₙ>;
32
+ };
33
+ ```
34
+
35
+ is equivalent to
36
+ ``` cpp
37
+ requires {
38
+ E1; requires C<decltype((E1))>;
39
+ E2; requires D<decltype((E2)), A₁, ⋯, Aₙ>;
40
+ };
41
+ ```
42
+
43
+ (including in the case where n is zero).
44
+ — *end example*]
45
+
46
+ [*Example 2*:
47
+
48
+ ``` cpp
49
+ template<typename T> concept C1 = requires(T x) {
50
+ {x++};
51
+ };
52
+ ```
53
+
54
+ The *compound-requirement* in `C1` requires that `x++` is a valid
55
+ expression. It is equivalent to the *simple-requirement* `x++;`.
56
+
57
+ ``` cpp
58
+ template<typename T> concept C2 = requires(T x) {
59
+ {*x} -> std::same_as<typename T::inner>;
60
+ };
61
+ ```
62
+
63
+ The *compound-requirement* in `C2` requires that `*x` is a valid
64
+ expression, that `typename T::inner` is a valid type, and that
65
+ `std::same_as<decltype((*x)), typename T::inner>` is satisfied.
66
+
67
+ ``` cpp
68
+ template<typename T> concept C3 =
69
+ requires(T x) {
70
+ {g(x)} noexcept;
71
+ };
72
+ ```
73
+
74
+ The *compound-requirement* in `C3` requires that `g(x)` is a valid
75
+ expression and that `g(x)` is non-throwing.
76
+
77
+ — *end example*]
78
+