tmp/tmpuc9lrcho/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
### Concept definitions <a id="temp.concept">[[temp.concept]]</a>
|
| 2 |
+
|
| 3 |
+
A *concept* is a template that defines constraints on its template
|
| 4 |
+
arguments.
|
| 5 |
+
|
| 6 |
+
``` bnf
|
| 7 |
+
concept-definition:
|
| 8 |
+
concept concept-name '=' constraint-expression ';'
|
| 9 |
+
```
|
| 10 |
+
|
| 11 |
+
``` bnf
|
| 12 |
+
concept-name:
|
| 13 |
+
identifier
|
| 14 |
+
```
|
| 15 |
+
|
| 16 |
+
A *concept-definition* declares a concept. Its *identifier* becomes a
|
| 17 |
+
*concept-name* referring to that concept within its scope.
|
| 18 |
+
|
| 19 |
+
[*Example 1*:
|
| 20 |
+
|
| 21 |
+
``` cpp
|
| 22 |
+
template<typename T>
|
| 23 |
+
concept C = requires(T x) {
|
| 24 |
+
{ x == x } -> std::convertible_to<bool>;
|
| 25 |
+
};
|
| 26 |
+
|
| 27 |
+
template<typename T>
|
| 28 |
+
requires C<T> // C constrains f1(T) in constraint-expression
|
| 29 |
+
T f1(T x) { return x; }
|
| 30 |
+
|
| 31 |
+
template<C T> // C, as a type-constraint, constrains f2(T)
|
| 32 |
+
T f2(T x) { return x; }
|
| 33 |
+
```
|
| 34 |
+
|
| 35 |
+
— *end example*]
|
| 36 |
+
|
| 37 |
+
A *concept-definition* shall appear at namespace scope
|
| 38 |
+
[[basic.scope.namespace]].
|
| 39 |
+
|
| 40 |
+
A concept shall not have associated constraints [[temp.constr.decl]].
|
| 41 |
+
|
| 42 |
+
A concept is not instantiated [[temp.spec]].
|
| 43 |
+
|
| 44 |
+
[*Note 1*: A concept-id [[temp.names]] is evaluated as an expression. A
|
| 45 |
+
concept cannot be explicitly instantiated [[temp.explicit]], explicitly
|
| 46 |
+
specialized [[temp.expl.spec]], or partially specialized. — *end note*]
|
| 47 |
+
|
| 48 |
+
The *constraint-expression* of a *concept-definition* is an unevaluated
|
| 49 |
+
operand [[expr.context]].
|
| 50 |
+
|
| 51 |
+
The first declared template parameter of a concept definition is its
|
| 52 |
+
*prototype parameter*. A *type concept* is a concept whose prototype
|
| 53 |
+
parameter is a type *template-parameter*.
|
| 54 |
+
|