tmp/tmpcpib3qjn/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#### Concept-dependent constraints <a id="temp.constr.concept">[[temp.constr.concept]]</a>
|
| 2 |
+
|
| 3 |
+
A *concept-dependent constraint* `CD` is an atomic constraint whose
|
| 4 |
+
expression is a concept-id `CI` whose *concept-name* names a dependent
|
| 5 |
+
concept named `C`.
|
| 6 |
+
|
| 7 |
+
To determine if `CD` is *satisfied*, the parameter mapping and template
|
| 8 |
+
arguments are first substituted into `C`. If substitution results in an
|
| 9 |
+
invalid concept-id in the immediate context of the constraint
|
| 10 |
+
[[temp.deduct.general]], the constraint is not satisfied. Otherwise, let
|
| 11 |
+
`CI'` be the normal form [[temp.constr.normal]] of the concept-id after
|
| 12 |
+
substitution of `C`.
|
| 13 |
+
|
| 14 |
+
[*Note 1*: Normalization of `CI` might be ill-formed; no diagnostic is
|
| 15 |
+
required. — *end note*]
|
| 16 |
+
|
| 17 |
+
To form `CI''`, each appearance of `C`'s template parameters in the
|
| 18 |
+
parameter mappings of the atomic constraints (including
|
| 19 |
+
concept-dependent constraints) in `CI'` is substituted with their
|
| 20 |
+
respective arguments from the parameter mapping of `CD` and the
|
| 21 |
+
arguments of `CI`.
|
| 22 |
+
|
| 23 |
+
`CD` is satisfied if `CI''` is satisfied.
|
| 24 |
+
|
| 25 |
+
[*Note 2*: Checking whether `CI''` is satisfied can lead to further
|
| 26 |
+
normalization of concept-dependent constraints. — *end note*]
|
| 27 |
+
|
| 28 |
+
[*Example 1*:
|
| 29 |
+
|
| 30 |
+
``` cpp
|
| 31 |
+
template<typename>
|
| 32 |
+
concept C = true;
|
| 33 |
+
|
| 34 |
+
template<typename T, template<typename> concept CC>
|
| 35 |
+
concept D = CC<T>;
|
| 36 |
+
|
| 37 |
+
template<typename U,
|
| 38 |
+
template<typename> concept CT,
|
| 39 |
+
template<typename, template<typename> concept> concept CU>
|
| 40 |
+
int f() requires CU<U, CT>;
|
| 41 |
+
int i = f<int, C, D>();
|
| 42 |
+
```
|
| 43 |
+
|
| 44 |
+
In this example, the associated constraints of `f` consist of a
|
| 45 |
+
concept-dependent constraint whose expression is the concept-id
|
| 46 |
+
`CU<U, CT>` with the mapping `U` ↦ `U`, `CT` ↦ `CT`, `CU` ↦ `CU`. The
|
| 47 |
+
result of substituting `D` into this expression is `D<U, CT>`. We
|
| 48 |
+
consider the normal form of the resulting concept-id, which is `CC<T>`
|
| 49 |
+
with the mapping `T` ↦ `U`, `CC` ↦ `CT`. By recursion, `C` is
|
| 50 |
+
substituted into `CC<T>`, and the result is normalized to the atomic
|
| 51 |
+
constraint `true`, which is satisfied.
|
| 52 |
+
|
| 53 |
+
— *end example*]
|
| 54 |
+
|