[temp.constr.order] (original) (raw)
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 Qif and only if, for every disjunctive clause in the disjunctive normal form110of P, subsumes every conjunctive clause in the conjunctive normal form111of 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 constraintB 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 Bif they are compatible for subsumption, have the same fold-operator, and the constraint of A subsumes that of B.
[Example 1:
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.
— _end note_]
The associated constraints C of a declaration D are eligible for subsumptionunless C contains a concept-dependent constraint.
A declaration D1 isat least as constrained as a declaration D2 if
- D1 and D2 are both constrained declarations andD1's associated constraints are eligible for subsumption and subsume those of D2; or
- D2 has no associated constraints.
A declaration D1 is more constrainedthan 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); template<C2 T> void f(T); template<typename T> void g(T); template<C1 T> void g(T); f(0); f((int*)0); g(true); g(0); — _end example_]
[Example 3: template<template<typename T> concept CT, typename T> struct S {};template<typename T> concept A = true;template<template<typename T> concept X, typename T> int f(S<X, T>) requires A<T> { return 42; } template<template<typename T> concept X, typename T> int f(S<X, T>) requires X<T> { return 43; }f(S<A, int>{}); — _end example_]
A non-template function F1 is more partial-ordering-constrainedthan a non-template function F2 if
- they have the same non-object-parameter-type-lists ([dcl.fct]), and
- if they are member functions, both are direct members of the same class, and
- if both are non-static member functions, they have the same types for their object parameters, and
- the declaration of F1 is more constrained than the declaration of F2.