mardi 9 août 2022

Using declaration to abbreviate type of a template in c++ [duplicate]

The following code snippet generates compile error with gcc, but not with clang or msvc:

template <class T, class U, class V>
class A
{

};

class B
{
    using A = A<int, float, double>;
};

Here you can see the example also: https://godbolt.org/z/3nTEfGza3
Most recent gcc emits the following error message:
error: declaration of 'using B::A = class A<int, float, double>' changes meaning of 'A' [-fpermissive]
If I change the new name from A to something else the error disappears.
My question is that which compiler is right? I thought that I can use this expression to abbreviate the template type, but gcc does not let me to do it.

Aucun commentaire:

Enregistrer un commentaire