Boost logo

Boost :

From: David Abrahams (david.abrahams_at_[hidden])
Date: 2001-12-06 17:37:25


----- Original Message -----
From: "the_dilster" <dylan_at_[hidden]>
To: <boost_at_[hidden]>
> >
> The problem was the interface - I wanted to be able to write no more
> than above to use it, or wasn't worth the effort.

Oh, well what you have below isn't an iterator, though: the pointer,
reference, and value_type are wrong, unless the member function happens to
return a reference to C. Anyone can make a simple "iterator", but making an
iterator can be tricky ;-)

> > > For the curious, my initial implementation is exceedingly simple,
> ie:
> > >
> > > template <class T, class I, class C = I::value_type>
> > > struct member_iterator : I
> > > {
> > > member_iterator() { }
> > > member_iterator(const I& i, T C::* m = 0) : I(i), m_member(m)
> { }
> > > T& operator* () { return I::operator*().*m_member; }
> > > private:
> > > T C::* m_member;
> > > };
> > >


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk