82 lines
3.2 KiB
Markdown
82 lines
3.2 KiB
Markdown
[temp.constr.concept]
|
||
|
||
# 13 Templates [[temp]](./#temp)
|
||
|
||
## 13.5 Template constraints [[temp.constr]](temp.constr#concept)
|
||
|
||
### 13.5.2 Constraints [[temp.constr.constr]](temp.constr.constr#temp.constr.concept)
|
||
|
||
#### 13.5.2.4 Concept-dependent constraints [temp.constr.concept]
|
||
|
||
[1](#1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/templates.tex#L1857)
|
||
|
||
A [*concept-dependent constraint*](#def:constraint,concept-dependent "13.5.2.4 Concept-dependent constraints [temp.constr.concept]") CD is
|
||
an atomic constraint whose expression is a concept-id CI whose[*concept-name*](temp.concept#nt:concept-name "13.7.9 Concept definitions [temp.concept]") names a dependent concept named C[.](#1.sentence-1)
|
||
|
||
[2](#2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/templates.tex#L1862)
|
||
|
||
To determine if CD is[*satisfied*](#def:constraint,satisfaction,concept-dependent "13.5.2.4 Concept-dependent constraints [temp.constr.concept]"),
|
||
the parameter mapping and template arguments are first
|
||
substituted into C[.](#2.sentence-1)
|
||
|
||
If substitution results in an invalid concept-id in
|
||
the immediate context of the constraint ([[temp.deduct.general]](temp.deduct.general "13.10.3.1 General")),
|
||
the constraint is not satisfied[.](#2.sentence-2)
|
||
|
||
Otherwise, let CIâ² be
|
||
the normal form ([[temp.constr.normal]](temp.constr.normal "13.5.4 Constraint normalization")) of the concept-id
|
||
after substitution of C[.](#2.sentence-3)
|
||
|
||
[*Note [1](#note-1)*:
|
||
|
||
Normalization of CI might be ill-formed; no diagnostics is required[.](#2.sentence-4)
|
||
|
||
â *end note*]
|
||
|
||
[3](#3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/templates.tex#L1877)
|
||
|
||
To form CIâ²â²,
|
||
each appearance of C's template parameters in
|
||
the parameter mappings of the atomic constraints
|
||
(including concept-dependent constraints)
|
||
in CIâ² is substituted with their respective arguments from
|
||
the parameter mapping of CD and the arguments of CI[.](#3.sentence-1)
|
||
|
||
[4](#4)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/templates.tex#L1886)
|
||
|
||
CD is satisfied if CIâ²â² is satisfied[.](#4.sentence-1)
|
||
|
||
[*Note [2](#note-2)*:
|
||
|
||
Checking whether CIâ²â² is satisfied
|
||
can lead to further normalization of concept-dependent constraints[.](#4.sentence-2)
|
||
|
||
â *end note*]
|
||
|
||
[*Example [1](#example-1)*: template<typename>concept C = true;
|
||
|
||
template<typename T, template<typename> concept CC>concept D = CC<T>;
|
||
|
||
template<typename U, template<typename> concept CT, template<typename, template<typename> concept> concept CU>int f() requires CU<U, CT>;int i = f<int, C, D>();
|
||
|
||
In this example, the associated constraints of f consist of a concept-dependent constraint
|
||
whose expression is the concept-id CU<U, CT> with the mappingUâ¦U,CTâ¦CT,CUâ¦CU[.](#4.sentence-3)
|
||
|
||
The result of substituting D into this expression is D<U, CT>[.](#4.sentence-4)
|
||
|
||
We consider the normal form of the resulting concept-id,
|
||
which is CC<T> with the mappingTâ¦U,CCâ¦CT[.](#4.sentence-5)
|
||
|
||
By recursion, C is substituted into CC<T>, and the result
|
||
is normalized to the atomic constraint true, which is satisfied[.](#4.sentence-6)
|
||
|
||
â *end example*]
|