|
Boost : |
From: the_dilster (dylan_at_[hidden])
Date: 2001-12-06 17:23:12
--- In boost_at_y..., "David Abrahams" <david.abrahams_at_r...> wrote:
>
> I presume you're talking about the iterator adapter library
policies?
>
> It should be pretty straightforward: You'd store the member
function pointer
> in the policies class. A much simpler way to get there, though,
might be to
> pass an instance of the standard adapters to transform_iterator or
> projection_iterator, whichever is appropriate.
>
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.
> > 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;
> > };
> >
> > Which requires the use of a pointer_iterator wrapper for vectors
(I
> > can't see how to avoid this anyway for certain compilers that
don't
> > support partial specialisation). It would be nice
> > if "pointer_iterator" was standard actually...or at least in
boost...
>
> ???
> Maybe you should describe what "pointer_iterator" is supposed to
be...
>
Um well, I thought it was kinda obvious...it's basically a wrapper
around a raw pointer that supplies value_type, distance_type and
iterator_category. For implementations that use pointers for vector
iterators, you just create pointer_vectors as needed and then
templates that require the iterator typedef's will work correctly.
Really only needed because VC++ doesn't support iterator_traits
properly.
Dylan
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk