
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