Boost.Range too focused on iterators?

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 *

On Fri, Jul 10, 2009 at 7:09 PM, j j<jjjaccck@gmail.com> wrote:
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 *
If you use something like a counting iterator (http://www.boost.org/doc/libs/1_39_0/libs/iterator/doc/counting_iterator.htm...), you can get the range you want just with iterator ranges. Iterators are sufficiently generic and adaptable a concept to get pretty much whatever range you want. Stuart Dootson
participants (2)
-
j j
-
Stuart Dootson