Files
2025-10-25 03:02:53 +03:00

82 lines
3.2 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[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.4Concept-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.9Concept 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.4Concept-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.1General")),
the constraint is not satisfied[.](#2.sentence-2)
Otherwise, let CI′ be
the normal form ([[temp.constr.normal]](temp.constr.normal "13.5.4Constraint 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*]