C++ Logo

STD-DISCUSSION

Advanced search

Subject: Re: requires-clause, pack expansion and constraints-ordering
From: Edward Catmur (ecatmur_at_[hidden])
Date: 2021-03-28 07:44:00


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.

 

Ed

 

From: Tobias Loew via Std-Discussion
Sent: 28 March 2021 13:10
To: std-discussion@lists.isocpp.org
Cc: tobi@die-loews.de
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.

 

Tobias

 

 

--

Std-Discussion mailing list

Std-Discussion@lists.isocpp.org

https://lists.isocpp.org/mailman/listinfo.cgi/std-discussion

 


STD-DISCUSSION list run by std-discussion-owner@lists.isocpp.org

Older Archives on Google Groups