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

3.2 KiB
Raw Permalink Blame History

[temp.constr.concept]

13 Templates [temp]

13.5 Template constraints [temp.constr]

13.5.2 Constraints [temp.constr.constr]

13.5.2.4 Concept-dependent constraints [temp.constr.concept]

1

#

A concept-dependent constraint CD is an atomic constraint whose expression is a concept-id CI whoseconcept-name names a dependent concept named C.

2

#

To determine if CD issatisfied, the parameter mapping and template arguments are first substituted into C.

If substitution results in an invalid concept-id in the immediate context of the constraint ([temp.deduct.general]), the constraint is not satisfied.

Otherwise, let CI′ be the normal form ([temp.constr.normal]) of the concept-id after substitution of C.

[Note 1:

Normalization of CI might be ill-formed; no diagnostics is required.

— end note]

3

#

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.

4

#

CD is satisfied if CI′′ is satisfied.

[Note 2:

Checking whether CI′′ is satisfied can lead to further normalization of concept-dependent constraints.

— end note]

[Example 1: templateconcept C = true;

template<typename T, template concept CC>concept D = CC;

template<typename U, template concept CT, template<typename, template 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.

The result of substituting D into this expression is D<U, CT>.

We consider the normal form of the resulting concept-id, which is CC with the mappingT↦U,CC↦CT.

By recursion, C is substituted into CC, and the result is normalized to the atomic constraint true, which is satisfied.

— end example]