Can an alias be defined with the same name as parent template class in C++?

Viewed 37

In following example struct Derived<T> inherits from Base<T> and defines an alias to its parent with the name Base:

template <class T>
struct Base {
    Base(int) {}
};

template <class T>
struct Derived : Base<T> {
    using Base = Base<T>;
    Derived() : Base(1) {}
};

int main() {
    Derived<char> x;
}

Clang permits this code, but GCC prints the error:

error: declaration of 'using Base = struct Base<T>' changes meaning of 'Base' [-fpermissive]

Demo: https://gcc.godbolt.org/z/srMT7hdWr

Which compiler is right here?

0 Answers
Related