0

When declaring a type alias,

using T = XXX;

XXX can only be a type.

Why is it still necessary to include "typename" before XXX if XXX is a type alias internal to a templated class?

For example,

template <typename T> struct fred
{
    using T2 = T[2];
};

template <typename U> struct mary
{
    // why is typename necessary here?
    using M2 = typename fred <U>::T2;
    // this does not compile, even though type alias must refer to a type
    // using M2 = fred <U>::T2;
};

0 Answers0