|
Boost : |
Subject: [boost] [Iterator] Zip iterator for back_insert_iterators?
From: Kris Rousey (krousey_at_[hidden])
Date: 2008-09-09 11:25:18
I just tried to make a zip iterator out of two vector
back_insert_iterators and got a very curious compile failure:
/usr/include/boost/iterator/iterator_facade.hpp:653: error: invalid
parameter type 'void'
/usr/include/boost/iterator/iterator_facade.hpp:653: error: in
declaration 'typename boost::detail::operator_brackets_result<Derived,
Value, Reference>::type boost::iterator_facade<I, V, TC, R,
D>::operator[](Difference) const'
/usr/include/boost/iterator/iterator_facade.hpp:693: error: invalid
parameter type 'void'
/usr/include/boost/iterator/iterator_facade.hpp:693: error: in
declaration 'Derived& boost::iterator_facade<I, V, TC, R,
D>::operator+=(Difference)'
/usr/include/boost/iterator/iterator_facade.hpp:699: error: invalid
parameter type 'void'
/usr/include/boost/iterator/iterator_facade.hpp:699: error: in
declaration 'Derived& boost::iterator_facade<I, V, TC, R,
D>::operator-=(Difference)'
/usr/include/boost/iterator/iterator_facade.hpp:705: error: invalid
parameter type 'void'
/usr/include/boost/iterator/iterator_facade.hpp:705: error: in
declaration 'Derived boost::iterator_facade<I, V, TC, R,
D>::operator-(Difference) const'
It seems that even though back_insert_iterator has an output_iterator
tag, iterator_facade still trying to define random access operators.
If assignment and incrementing are the only valid operations on an
iterator (as is the case with output iterators), then doesn't it make
sense to support a difference_type of void? Is this a curiosity of my
stdlib implementation? A Boost.Iterator library oversight? A
Boost.Iterator conscious design decision? Or a loose nut behind the
keyboard trying something he shouldn't?
I'm using version 1.35.0 on Ubuntu 8.04 x86_64 with g++ version 4.2.3.
Here's the code I used to get this error:
#include <iterator>
#include <iostream>
#include <boost/iterator/zip_iterator.hpp>
#include <vector>
#include <algorithm>
using namespace std;
using namespace boost;
int main()
{
vector<int> ha1;
vector<double> ha2;
make_zip_iterator( make_tuple( back_inserter(ha1), back_inserter(ha2) ) );
return 0;
}
Thanks,
Kris
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk