C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Potential defect in the standard when disambiguating function templates when one of them contains a pack

From: Anoop Rana <ranaanoop986_at_[hidden]>
Date: Sun, 19 Jun 2022 00:02:00 +0530
>
> Did you post a bug report to the vendor? What was their response?
>

Here is the bug report
<https://developercommunity.visualstudio.com/t/MSVC-fails-to-disambiguate-between-funct/10074731>
that I submitted.

On Sat, 18 Jun 2022 at 22:10, Jens Maurer <Jens.Maurer_at_[hidden]> wrote:

> On 18/06/2022 14.26, Anoop Rana via Std-Proposals wrote:
> > I was working with parameter packs when I noticed that one such
> case(given below) doesn't compile in msvc but compiles fine in gcc and
> clang. Here is the link for the verification of the same: link to demo <
> https://godbolt.org/z/6hf7Ys1Tz>
> >
> > The code is as follows:
> >
> > template<typename T> struct C{};
> >
> > template<typename T> void f(C<T>)
> > {
> >
> > }
> > template<typename... T> void f(C<T...>)
> > {
> >
> > }
> > int main()
> > {
> > f(C<int>{}); //Should this call succeed?
> > }
> >
> > I want to know if the above example is well-formed according to the
> standard. I mean should the call /f(C<int>{}); /succeed by choosing the
> first overload version `/void f(C<T>)/` over the second version.
> >
> > For possible explanation i looked at examples given in:
> temp.deduct.type#9.2 <
> https://timsong-cpp.github.io/cppwp/n4861/temp.deduct.type#9.2>:
> > [Example
> >
> > template<class T1, class... Z> class S;
> // #1
> > template<class T1, class... Z> class S<T1, const Z&...> { };
> // #2
> > template<class T1, class T2> class S<T1, const T2&> { };
> // #3
> > S<int, const int&> s; // both #2 and #3 match; #3 is more
> specialized
> >
> > End Example]
>
> Could you make C take a pack of T? Does the issue reproduce?
>
> > My current understanding/intuition is that the example that I gave here <
> https://godbolt.org/z/6hf7Ys1Tz> should be valid as well and the first
> overload should be chosen over the second.
>
> > *If so*, should this or a similar example be added in temp.deduct.type
> to make this more clear?
>
> Did you post a bug report to the vendor? What was their response?
>
> Jens
>

Received on 2022-06-18 18:32:13