C++ Logo

std-discussion

Advanced search

Template template parameters and CTAD

From: Ell <ell_se_at_[hidden]>
Date: Mon, 22 Sep 2025 10:11:13 +0300
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.

Received on 2025-09-22 07:11:28