# 13 Templates [temp]

## 13.5 Template constraints [temp.constr]

### 13.5.5 Partial ordering by constraints [temp.constr.order]

A constraint P subsumes a constraint Q if and only if, for every disjunctive clause in the disjunctive normal form113 of P, subsumes every conjunctive clause in the conjunctive normal form114 of Q, where
• a disjunctive clause subsumes a conjunctive clause if and only if there exists an atomic constraint in for which there exists an atomic constraint in such that subsumes ,
• an atomic constraint A subsumes another atomic constraint B if and only if A and B are identical using the rules described in [temp.constr.atomic], and
• a fold expanded constraint A subsumes another fold expanded constraint B if they are compatible for subsumption, have the same fold-operator, and the constraint of A subsumes that of B.
[Example 1:
Let A and B be atomic constraints.
The constraint A  ∧ B subsumes A, but A does not subsume A  ∧ B.
The constraint A subsumes A  ∨ B, but A  ∨ B does not subsume A.
Also note that every constraint subsumes itself.
— end example]
[Note 1:
The subsumption relation defines a partial ordering on constraints.
This partial ordering is used to determine
— end note]
A declaration D1 is at least as constrained as a declaration D2 if
• D1 and D2 are both constrained declarations and D1's associated constraints subsume those of D2; or
• D2 has no associated constraints.
A declaration D1 is more constrained than another declaration D2 when D1 is at least as constrained as D2, and D2 is not at least as constrained as D1.
[Example 2: template<typename T> concept C1 = requires(T t) { --t; }; template<typename T> concept C2 = C1<T> && requires(T t) { *t; }; template<C1 T> void f(T); // #1 template<C2 T> void f(T); // #2 template<typename T> void g(T); // #3 template<C1 T> void g(T); // #4 f(0); // selects #1 f((int*)0); // selects #2 g(true); // selects #3 because C1<bool> is not satisfied g(0); // selects #4 — end example]
113)113)
A constraint is in disjunctive normal form when it is a disjunction of clauses where each clause is a conjunction of atomic constraints.
For atomic constraints A, B, and C, the disjunctive normal form of the constraint A  ∧ (B  ∨ C) is (A  ∧ B)  ∨ (A  ∧ C).
Its disjunctive clauses are (A  ∧ B) and (A  ∧ C).
114)114)
A constraint is in conjunctive normal form when it is a conjunction of clauses where each clause is a disjunction of atomic constraints.
For atomic constraints A, B, and C, the constraint A  ∧ (B  ∨ C) is in conjunctive normal form.
Its conjunctive clauses are A and (B  ∨ C).