[zip_iterator] Understanding why.

Zip iterator implements the functionality I need to advance associated iterators through different ranges, but it seems strangly awkward to use, which is odd for Boost. so I'm wondering if I've misunderstood the design paradigms. Given two ranges (say vectors), I'd like to be able to generate an iterable composite, anditerate through that, something like vector<int> v1; vector<int> v2; typedef zip_composite<int, int> Z; Z zip( v1, v2 ); for ( Z::iterator i=zip.begin( ); i !=zip.end( ); ++i ) { // ... blah, blah, blah } Is this impossible or undesirable to implement for reasons I've not realized? Thanks, Rob.

-------------------------------------------------- From: "Robert Jones" <robertgbjones@gmail.com> Sent: Monday, October 27, 2008 9:24 AM To: "Boost Developers" <boost@lists.boost.org> Subject: [boost] [zip_iterator] Understanding why.
Zip iterator implements the functionality I need to advance associated iterators through different ranges, but it seems strangly awkward to use, which is odd for Boost. so I'm wondering if I've misunderstood the design paradigms.
I'm not the author, but I think the design is reasonable in the context of the time it was written (which predates the Boost.Range library).
Given two ranges (say vectors), I'd like to be able to generate an iterable composite, anditerate through that, something like
vector<int> v1; vector<int> v2;
typedef zip_composite<int, int> Z; Z zip( v1, v2 );
for ( Z::iterator i=zip.begin( ); i !=zip.end( ); ++i ) { // ... blah, blah, blah }
Is this impossible or undesirable to implement for reasons I've not realized?
Fusion has this exact paradigm in the zip_view.. for compile-time iterators so it's certainly possible. Perhaps you could submit something based on Boost.Range as an extension? :D
Thanks, Rob. _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Cheers, Brandon

On Mon, Oct 27, 2008 at 7:24 AM, Robert Jones <robertgbjones@gmail.com> wrote:
Given two ranges (say vectors), I'd like to be able to generate an iterable composite, anditerate through that, something like
vector<int> v1; vector<int> v2;
typedef zip_composite<int, int> Z; Z zip( v1, v2 );
for ( Z::iterator i=zip.begin( ); i !=zip.end( ); ++i ) { // ... blah, blah, blah }
In the RangeEx library in the vault (in the Algorithms directory) has some zip_range classes that appear to fit the above pattern (in range/combine.hpp). This library is currently sitting in the review queue and waiting for a review manager. Best, Stjepan

On Mon, Oct 27, 2008 at 7:24 AM, Robert Jones <robertgbjones@gmail.com> wrote:
Given two ranges (say vectors), I'd like to be able to generate an iterable composite, and iterate through that, something like
vector<int> v1; vector<int> v2;
typedef zip_composite<int, int> Z; Z zip( v1, v2 );
As written, this would require erasure of the range/container type. Such a thing is not impossible (google around for any_iterator) but is perhaps something for a range_ex_ex rather than range_ex.
participants (4)
-
Brandon Kohn
-
Peter Bartlett
-
Robert Jones
-
Stjepan Rajko