The reason is that the typedef
syntax is more variable than the inheritance syntax. Normally you would write typedef
first, and the type name second. But the order is actually unimportant. To wit, the following is a valid typedef
:
int typedef integer_type;
Now consider what happens if we use a dependent name:
S<T>::type typedef integer_type;
Without doing some non-trivial lookahead, the parser cannot know that S<T>::type
refers to a type name here (because it hasn’t yet seen the typedef
), so by the disambiguation rules it infers a value. For consistency in the grammar, there is no special case for prefixed typedef
(which, you are right, is unambiguous). There could be a special case, but there simply isn’t.