Iterator category
Posted
by Knowing me knowing you
on Stack Overflow
See other posts from Stack Overflow
or by Knowing me knowing you
Published on 2010-04-18T17:22:31Z
Indexed on
2010/04/18
17:23 UTC
Read the original article
Hit count: 230
In code:
//I know that to get this effect (being able to use it with std algorithms) I can inherit like I did in line below:
class Iterator //: public std::iterator<std::bidirectional_iterator_tag,T>
{
private:
T** itData_;
public:
//BUT I WOULD LIKE TO BE ABLE TO DO IT BY HAND AS WELL
typedef std::bidirectional_iterator_tag iterator_category;
typedef T* value_type;//SHOULD IT BE T AS value_type or T*?
typedef std::ptrdiff_t difference_type;
typedef T** pointer;//SHOULD IT BE T* AS pointer or T**?
typedef T*& reference;//SHOULD IT BE T& AS reference or T*&?
};
Basically what I'm asking is if I have my variable of type T** in iterator class is it right assumption that value type for this iterator will be T* and so on as I described in comments in code, right next to relevant lines.
Thank you.
© Stack Overflow or respective owner