Boost logo

Boost :

Subject: [boost] Boost.Range too focused on iterators?
From: j j (jjjaccck_at_[hidden])
Date: 2009-07-10 14:09:53


The boost range library makes ranges similar to the to the STL
Container<http://www.sgi.com/Technology/STL/Container.html>concept. A
Range provides
*iterators* for accessing a half-open range [first,one_past_last) of
elements and provides information about the number of elements in the Range.

Wouldn't it be better if it could use *values* and iterators?
eg
template<class access> ostream& operator<<(ostream& out,const range<access>&
in){
 for(x temp=in.a;temp!=in.b;temp++)cout<<access()(temp);
 return out;
}

//Later on in code
//prints a range of numbers
cout<<Range<no_deref >(0,8); //no_deref is a function object that returns a
reference to its argument.
//prints the contents of a range of iterators.
string a="Hello World!";
cout<<Range(a.begin(),a.end()) //defaults to deref which is a function
object that derefences its argument with *


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk