Date: Mon, 22 Sep 2025 20:17:02 +0200
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
> 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
Received on 2025-09-22 18:17:09