On 22 Feb, 10:51, Rohit.ME...@rbos.com wrote:
Hi All
I want to overload the ++ and - operator for stl list iterator so that
I could do some thing additional in that
As want to set the current node status also
Can some one please post sample code to use this, I would NOT like to
do it by inheriting the iterator class. Rather I would like to keep a
member iterator and wrap the logic around it
template<class T, class AllocT>
class my_iterator
{
typedef list<T, AllocTlist_t;
public:
typedef typename list_t::value_type value_type;
typedef typename list_t::pointer pointer;
typedef typename list_t::reference reference;
...
my_iterator(base_t & b) : base_(b) {}
my_iterator operator ++ ()
{
++base_;
// do what you want
return *this;
}
bool operator != (my_iterator const & b) const
{
return base_ != b.base_;
}
reference operator * ()
{
return *base_;
}
private:
typedef typename list_t::iterator base_t;
base_t base_;
};