C++ Logo


Advanced search

Re: requires-clause, pack expansion and constraints-ordering

From: Edward Catmur <ecatmur_at_[hidden]>
Date: Sun, 28 Mar 2021 13:44:00 +0100

You don’t need a(n explicit) pack expansion, or even for the pack to be non-empty. Simplifying your example to the point of absurdity:


template<classconcept Any = true;

template<class T> concept Sub = Any<T> && true;

template<Any = void, Any...> int foo();

template<Sub = void, Any...> int foo();

int x = foo(); // rejects-valid, ambiguous call to overloaded function


I’d class this as a bug in all compilers owing to incomplete coverage of the intersection between concepts and variadics. Yes it’s unusual for all compilers to have the same bug, but it isn’t unheard of.




From: Tobias Loew via Std-Discussion
Sent: 28 March 2021 13:10
To: std-discussion_at_[hidden]
Cc: tobi_at_[hidden]
Subject: [std-discussion] requires-clause, pack expansion and constraints-ordering


While playing with concepts and parameter-packs, I tried to expand a

pack inside a requires-clause:

It worked wrt. concept-checking but it failed to create the right

constraints-ordering for overload resolution.


Here is an example, showing the problem: https://godbolt.org/z/onnTYPzzj



According to N4861, [temp.variadic] (10.4) an expansion of a

fold-expression is mere a rewrite.

So, I would have expected, that constraints-ordering also works with

packs, but it seems that clang, gcc and msvc disagree.






Std-Discussion mailing list




Received on 2021-03-28 07:44:05