
I have seen your | operator. It is o.k. for unary things, like rng | filter( predicate ), but for binary things, it is a bit weird: rngA | difference(rngB) I find the alternatives clearer: rngA - rngB would be nice (but requires concept checking), or difference( rngA, rngB ). But regardless of notation, doesn't this suffer from the same problem that these objects are temporaries? Arno -----Original Message----- From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of Neil Groves Sent: Friday, August 29, 2008 2:56 PM To: boost@lists.boost.org Subject: Re: [boost] lifetime of ranges vs. iterators On Fri, Aug 29, 2008 at 1:50 PM, Arno Schödl <aschoedl@think-cell.com>wrote:
For iterators, the make_ helpers are great:
vector<int> vecnA; vector<int> vecnB;
DoSomethingWithRangeThatStoresIterators( make_difference_iterator( vecnA.begin(), vecnA,end(), vecnB.begin(), vecnB.end() ), make_difference_iterator( vecnA.end(), vecnA,end(), vecnB.end(), vecnB.end() ) );
The equivalent with ranges, supposedly easier, would now look like this:
vector<int> vecnA; vector<int> vecnB;
difference_range< int, int > diffrng( vecnA, vecnB ); // watch out with scope DoSomethingWithRangeThatStoresIterators( diffrng );
as opposed to the much nicer:
vector<int> vecnA; vector<int> vecnB;
DoSomethingWithRangeThatStoresIterators( make_difference_iterator( vecnA, vecnB ) );
If we drive this stacking to one or more levels, things pretty quickly become pretty ugly. Do we really want that?
No, we don't want that at all. Apologies for the shameless plug, but you might want to look at the range adaptors that use the '|' operator in the Boost.RangeEx proposal / update in the vault at: http://www.boostpro.com/vault/index.php?action=downloadfile&filename=range_ex.zip&directory=Algorithms The range adaptors and the pipe operator allow infix composition of range adaptors for the very reason you suggest. Neil Groves
Arno
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost -- Dr. Arno Schoedl · aschoedl@think-cell.com Technical Director think-cell Software GmbH · Invalidenstr. 34 · 10115 Berlin, Germany http://www.think-cell.com · phone +49-30-666473-10 · toll-free (US) +1-800-891-8091 Directors: Dr. Markus Hannebauer, Dr. Arno Schoedl · Amtsgericht Charlottenburg, HRB 85229