mardi 24 janvier 2017

Why does one still need to disambiguate a type with typename in the RHS of a using statement?

I know very well why one needs to use typename for dependent types, since the compiler may not be able to disambiguate between a type and a variable declaration when it sees something like T::type, see e.g. this answer for a great explanation.

However, in something like

using type = T::type;

there is nothing ambiguous. IMO, T::type should always be parsed as a type, as it's part of the RHS of a using statement. However, we still need to use the typename here,

using type = typename T::type;

Question: Is there any reason why this is not an exception to the typename rule in C++11 and later?

Aucun commentaire:

Enregistrer un commentaire