Search code examples
c++templateslanguage-lawyerc++-conceptsc++23

How are the immediately-declared constraint-expressions of type-constraints combined?


If C is a concept, are the following constructs equivalent?

template <C A, C B>
template <typename A, typename B>
requires C<A> && C<B>

In other words, are all the immediately-declared constraint-expressions associated with a type-constraint combined via conjunction (&&)?

I was unable to find any wording which confirms this. Note that this nuance is extremely important, because if a conjunction is used, then a template with C A and C B parameters would be more constrained than another with only C<A> or <B> constraints. If there is no conjunction, then neither is more constrained than the other.


Solution

  • Yes, they are combined to form the associated constraints by conjunction in a specified order which includes the type constraints introduced in the template parameter list in order of their appearance per [temp.constr.decl]/3.3.1.

    So the associated constraints are the same in both of your declarations: C<A> && C<B>