samedi 27 avril 2019

Why can templated aliases of anonymous struct/class-es not be defined directly?

I can create the following:

using Foo = struct { /*Implementation*/ };

template<class>
using Bar = Foo;

However the following is not allowed:

template<class>
using Bar = struct { /*Implementation*/ };

The error from Clang is more helpful than GCC, and states:

error: '(anonymous struct at file:line:column)' cannot be defined in a type alias template


Any reasons why the second code example is not allowed?

Note: Any citation from the standard is also helpful.

Aucun commentaire:

Enregistrer un commentaire