Why use typedef for iterators in template classes
I read the following post: Why use typedef-typename in templates
I am reading up on some material which says you must have public typedef
for the following private nested class
template<typename T>
class list
{
private:
class my_private_it
{
public:
...
};
public:
typedef my_private_it iterator;
// should this be:
// typedef typename my_private_it iterator;
...
iterator begin(){return iterator(this)};
iterator end(){return iterator(NULL)};
};
Now from the aforementioned link, I understand, the typename is to help
the compiler deduce that it is infact working with types and not values
for certain dependent names. But why do people use the typedef? Is this
compiler requirement or standard requirement. Please note I understand the
typename part , but not the typedef part.
No comments:
Post a Comment