Boost logo

Boost :

Subject: Re: [boost] [Iterator] Zip iterator for back_insert_iterators?
From: Kris Rousey (krousey_at_[hidden])
Date: 2008-09-09 16:04:17

2008/9/9 David Abrahams <dave_at_[hidden]>:

> Try this patch to boost/iterator/iterator_facade.hpp; does it fix the
> problem for you?

Yes. Well... It fixed THAT problem. After I took it a step further and
tried to use the iterator like this:

*iter = make_tuple(i, i*2.0);

I then get this error:

boost/tuple/detail/tuple_basic.hpp:377: error: no match for
'operator=' in '((boost::tuples::cons<void, boost::tuples::cons<void,
boost::tuples::null_type> >*)this)->boost::tuples::cons<void,
boost::tuples::cons<void, boost::tuples::null_type> >::head =
u->boost::tuples::cons<int, boost::tuples::cons<double,
boost::tuples::null_type> >::head'

After looking into it further, it seems that std::back_insert_iterator
inherits from std::iterator<std::output_iterator_tag, void, void,
void, void>. Since it obviously has no interest in populating the
right type information, would it make sense add partial
specializations to boost/detail/iterator.hpp to grab the appropriate
types from the container? e.g.

template <class CONTAINER>
struct iterator_traits<std::back_insert_iterator<CONTAINER> >
    typedef typename CONTAINER::value_type value_type;
    typedef typename CONTAINER::reference reference;
    typedef typename CONTAINER::pointer pointer;
    typedef typename CONTAINER::difference_type difference_type;
    typedef std::output_iterator_tag iterator_category;

I'll try this out and see if it works, but what is this the right way
to go about it? I'm fairly new to C++ and boost development, so I'm
looking to learn the correct ways.


Boost list run by bdawes at, gregod at, cpdaniel at, john at