From Scott Meyers's book, names in a template that are dependent on a template parameter are called dependent names. (When a dependent name is nested inside a class, I call it a nested dependent name)
So its necessary to use "typename" keyword before the dependent name, right?
template<typename C>
void print2nd(const C& container) {
typename C::const_iterator iter(container.begin());
...
}
But why in this code, taken from Josuttis book, std::vector that is another template's instantiation which is obviously dependent on T, they do not use "typename" here:
template <typename T>
class Stack {
(?typename?) std::vector<T> elems;
...
};
It all looks confusing especially with another example from Meyers:
template<typename IterT>
void workWithIterator(IterT iter) {
typename std::iterator_traits<IterT>::value_type temp(*iter);
... }
They look all the same to me. How do you differentiate?