Why using parent alias from a template derived class can't be deduced automatically?

49 Views Asked by At

In C++17, consider a base template class that has an alias to get the vectorized type of the enclosed type:

template<typename T>
struct Foo {
    using VectorType = vector<T>;
};

In a non-template derived class, we can simply use VectorType as:

struct Bar : public Foo<int> {
    VectorType Get(VectorType t) { return t; }
};

Now if we want to use it in a template derived class, we need to use using typename:

template<typename T>
struct BarT : public Foo<T> {
    using typename Foo<T>::VectorType;

    VectorType Get(VectorType t) { return t; }
};

From what I initially thought, it should be possible to be deduced automatically by the compiler, no?

Is there any better way such that I don't have to retype it for multiple aliases in the derived classes?

0

There are 0 best solutions below