C++ Logo

std-discussion

Advanced search

Re: Template template parameters and CTAD

From: Ell <ell_se_at_[hidden]>
Date: Mon, 22 Sep 2025 22:31:35 +0000
On September 22, 2025 6:17:02 PM UTC, Jens Maurer <jens.maurer_at_[hidden]> wrote:
>
>
>On 9/22/25 09:11, Ell via Std-Discussion wrote:
>> Consider this:
>>
>> template <class T, class U = long>
>> struct A { A (T, U); };
>>
>> template <class T>
>> using B = A<T>;
>>
>> template <template <class> class P>
>> P x (1, 2);
>>
>> The type of x<B> is A<int, long>, as expected. However, the type of X<A>
>> is A<int, int>, which is surprising. I'd expect it to either
>> be A<int, long>, as if P were an alias template, or to be ill formed,
>> since the deduced type doesn't match P.
>
>This is ill-formed; the name of a template template parameter is not
>a deducible template per the current rules, as clarified here:
>
>https://cplusplus.github.io/CWG/issues/3003.html
>
>If you wish to make this situation deducible, please submit a paper
>to EWG.
>
>Jens
>

Ah, thanks, I was confused by gcc and clang accepting this.

Received on 2025-09-22 22:31:49