samedi 24 avril 2021

Why is a template base class' public member types hidden by default?

template<typename T>
struct A
{
    using U = T;
};

template<typename T>
struct B : A<T>
{
    B(typename A<T>::U) {} // okay
    B(U) {} // error: unknown type name 'U'
};

int main()
{
    return typename B<int>::U{}; // okay
}

Why is a template base class' public member types hidden by default?

Aucun commentaire:

Enregistrer un commentaire