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<>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?
template<class access> ostream& operator<<(ostream& out,const range<access>&
 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, gregod at, cpdaniel at, john at