Code:
std::vector<T*>::iterator it;
Newer compilers expect to understand more about templated definitions at definition time (rather than waiting until instantiation time) while still not looking into the definitions of other templated classes while processing this definition.
As a result, the compiler does not know soon enough that "iterator" is a typename. (Older compilers didn't care that they didn't find that out until later).
Adding the keyword typename to the right place will fix it.
I have carefully avoided learning the exact rules for that use of "typename" because I think it is very ugly (the line may be complex enough it is unclear which name is qualified by "typename").
Instead, when typename is used for this purpose, I always use one or more extra typedef's so the keyword "typename" can come immediately after typedef and it can be very obvious which name it qualifies (the one that is after the only :: on the line and before the name being declared).
I haven't tested this, but from memory:
Code:
typedef std::vector<T*> container;
typedef typename container::iterator iterator;
iterator it;
I use the names "container" and "iterator" that way only in the common case that the current class deals with only one significant container or iterator type. If the class used more than one type of container or iterator, I would choose type names that say something about the purpose of the container or iterator within the current class.