[temp.constr.decl] (original) (raw)

When determining whether a given introducedconstraint-expression of a declaration in an instantiated specialization of a templated class is equivalent ([temp.over.link]) to the correspondingconstraint-expression of a declaration outside the class body, is instantiated.

If the instantiation results in an invalid expression, the constraint-expressions are not equivalent.

[Note 1:

This can happen when determining which member template is specialized by an explicit specialization declaration.

— _end note_]

[Example 2: template <class T> concept C = true;template <class T> struct A { template <class U> U f(U) requires C<typename T::type>; template <class U> U f(U) requires C<T>; };template <> template <class U>U A<int>::f(U u) requires C<int> { return u; }

Substituting int for T in C<typename T​::​type>produces an invalid expression, so the specialization does not match #1.

Substituting int for T in C<T> produces C<int>, which is equivalent to the constraint-expression for the specialization, so it does match #2.

— _end example_]