[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

[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

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