tmp/tmpvfgkvygi/{from.md → to.md}
RENAMED
|
@@ -19,12 +19,11 @@ requirement-body:
|
|
| 19 |
'{' requirement-seq '}'
|
| 20 |
```
|
| 21 |
|
| 22 |
``` bnf
|
| 23 |
requirement-seq:
|
| 24 |
-
requirement
|
| 25 |
-
requirement requirement-seq
|
| 26 |
```
|
| 27 |
|
| 28 |
``` bnf
|
| 29 |
requirement:
|
| 30 |
simple-requirement
|
|
@@ -32,12 +31,11 @@ requirement:
|
|
| 32 |
compound-requirement
|
| 33 |
nested-requirement
|
| 34 |
```
|
| 35 |
|
| 36 |
A *requires-expression* is a prvalue of type `bool` whose value is
|
| 37 |
-
described below.
|
| 38 |
-
unevaluated operands [[term.unevaluated.operand]].
|
| 39 |
|
| 40 |
[*Example 1*:
|
| 41 |
|
| 42 |
A common use of *requires-expression*s is to define requirements in
|
| 43 |
concepts such as the one below:
|
|
@@ -64,38 +62,43 @@ The first `requires` introduces the *requires-clause*, and the second
|
|
| 64 |
introduces the *requires-expression*.
|
| 65 |
|
| 66 |
— *end example*]
|
| 67 |
|
| 68 |
A *requires-expression* may introduce local parameters using a
|
| 69 |
-
*parameter-declaration-clause*
|
| 70 |
-
*requires-expression* shall not have a default argument.
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
|
|
|
| 75 |
|
| 76 |
[*Example 2*:
|
| 77 |
|
| 78 |
``` cpp
|
| 79 |
template<typename T>
|
| 80 |
concept C = requires(T t, ...) { // error: terminates with an ellipsis
|
| 81 |
t;
|
| 82 |
};
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
```
|
| 84 |
|
| 85 |
— *end example*]
|
| 86 |
|
| 87 |
-
The substitution of template arguments into a *requires-expression*
|
| 88 |
-
result in the formation of invalid types or expressions in
|
| 89 |
-
*requirement*s or the violation
|
| 90 |
-
*requirement*s. In such cases, the
|
| 91 |
-
`false`; it does not cause the
|
| 92 |
-
|
| 93 |
-
and stops when a condition that
|
| 94 |
-
*requires-expression* is encountered. If
|
| 95 |
-
semantic constraint checking succeed, the
|
| 96 |
-
evaluates to `true`.
|
| 97 |
|
| 98 |
[*Note 1*: If a *requires-expression* contains invalid types or
|
| 99 |
expressions in its *requirement*s, and it does not appear within the
|
| 100 |
declaration of a templated entity, then the program is
|
| 101 |
ill-formed. — *end note*]
|
|
@@ -107,11 +110,11 @@ diagnostic required.
|
|
| 107 |
[*Example 3*:
|
| 108 |
|
| 109 |
``` cpp
|
| 110 |
template<typename T> concept C =
|
| 111 |
requires {
|
| 112 |
-
new
|
| 113 |
};
|
| 114 |
```
|
| 115 |
|
| 116 |
— *end example*]
|
| 117 |
|
|
|
|
| 19 |
'{' requirement-seq '}'
|
| 20 |
```
|
| 21 |
|
| 22 |
``` bnf
|
| 23 |
requirement-seq:
|
| 24 |
+
requirement requirement-seqₒₚₜ
|
|
|
|
| 25 |
```
|
| 26 |
|
| 27 |
``` bnf
|
| 28 |
requirement:
|
| 29 |
simple-requirement
|
|
|
|
| 31 |
compound-requirement
|
| 32 |
nested-requirement
|
| 33 |
```
|
| 34 |
|
| 35 |
A *requires-expression* is a prvalue of type `bool` whose value is
|
| 36 |
+
described below.
|
|
|
|
| 37 |
|
| 38 |
[*Example 1*:
|
| 39 |
|
| 40 |
A common use of *requires-expression*s is to define requirements in
|
| 41 |
concepts such as the one below:
|
|
|
|
| 62 |
introduces the *requires-expression*.
|
| 63 |
|
| 64 |
— *end example*]
|
| 65 |
|
| 66 |
A *requires-expression* may introduce local parameters using a
|
| 67 |
+
*parameter-declaration-clause*. A local parameter of a
|
| 68 |
+
*requires-expression* shall not have a default argument. The type of
|
| 69 |
+
such a parameter is determined as specified for a function parameter in
|
| 70 |
+
[[dcl.fct]]. These parameters have no linkage, storage, or lifetime;
|
| 71 |
+
they are only used as notation for the purpose of defining
|
| 72 |
+
*requirement*s. The *parameter-declaration-clause* of a
|
| 73 |
+
*requirement-parameter-list* shall not terminate with an ellipsis.
|
| 74 |
|
| 75 |
[*Example 2*:
|
| 76 |
|
| 77 |
``` cpp
|
| 78 |
template<typename T>
|
| 79 |
concept C = requires(T t, ...) { // error: terminates with an ellipsis
|
| 80 |
t;
|
| 81 |
};
|
| 82 |
+
template<typename T>
|
| 83 |
+
concept C2 = requires(T p[2]) {
|
| 84 |
+
(decltype(p))nullptr; // OK, p has type ``pointer to T''
|
| 85 |
+
};
|
| 86 |
```
|
| 87 |
|
| 88 |
— *end example*]
|
| 89 |
|
| 90 |
+
The substitution of template arguments into a *requires-expression* can
|
| 91 |
+
result in the formation of invalid types or expressions in the immediate
|
| 92 |
+
context of its *requirement*s [[temp.deduct.general]] or the violation
|
| 93 |
+
of the semantic constraints of those *requirement*s. In such cases, the
|
| 94 |
+
*requires-expression* evaluates to `false`; it does not cause the
|
| 95 |
+
program to be ill-formed. The substitution and semantic constraint
|
| 96 |
+
checking proceeds in lexical order and stops when a condition that
|
| 97 |
+
determines the result of the *requires-expression* is encountered. If
|
| 98 |
+
substitution (if any) and semantic constraint checking succeed, the
|
| 99 |
+
*requires-expression* evaluates to `true`.
|
| 100 |
|
| 101 |
[*Note 1*: If a *requires-expression* contains invalid types or
|
| 102 |
expressions in its *requirement*s, and it does not appear within the
|
| 103 |
declaration of a templated entity, then the program is
|
| 104 |
ill-formed. — *end note*]
|
|
|
|
| 110 |
[*Example 3*:
|
| 111 |
|
| 112 |
``` cpp
|
| 113 |
template<typename T> concept C =
|
| 114 |
requires {
|
| 115 |
+
new decltype((void)T{}); // ill-formed, no diagnostic required
|
| 116 |
};
|
| 117 |
```
|
| 118 |
|
| 119 |
— *end example*]
|
| 120 |
|