[rangelib]Any interest or plans for boost review?

http://www.torjo.com/code/rangelib15.zip is currently used in: http://cvs.sourceforge.net/viewcvs.py/boost-sandbox/boost-sandbox/boost/fiel... Are there any plans to request a formal review so that it's eventually in boost? I tried boost/range; however, as indicated by comments in the above code, I had no luck.

Larry Evans <cppljevans <at> cox-internet.com> writes:
http://www.torjo.com/code/rangelib15.zip is currently used in:
sandbox/boost/fields_visitor/fields_visitor.hpp
Are there any plans to request a formal review so that it's eventually in boost? I tried boost/range; however, as indicated by comments in the above code, I had no luck.
Could you make an small example that shows what you want to do and why boost.range cannot do it? Thanks -Thorsten

On 07/01/2005 06:47 AM, Thorsten Ottosen wrote:
Larry Evans <cppljevans <at> cox-internet.com> writes: [snip]
Are there any plans to request a formal review so that it's eventually in boost? I tried boost/range; however, as indicated by comments in the above code, I had no luck.
Could you make an small example that shows what you want to do and why boost.range cannot do it?
What I want is: <-------- cut here -------- #include <utility> using namespace std; template<class StlContainer> struct const_iter_range : private std::pair < typename StlContainer::const_iterator , typename StlContainer::const_iterator > { typedef typename StlContainer::const_iterator iter_type ; typedef typename StlContainer::const_reference const_reference ; typedef std::pair<iter_type,iter_type> super_type ; const_iter_range(StlContainer const& a_container) : super_type(a_container.begin(), a_container.end()) {} const_reference operator*(void)const { return *(this->first); } void operator++(void) { ++(this->first); } bool empty(void)const { return (this->first) == (this->second); } };
-------- cut here -------- However, when I tested boost/range by copying and then simplifying libs/range/test/iterator_range.hpp, the closest I got was: <-------- cut here --------
typedef string::iterator iterator; typedef iterator_range<iterator> irange; string str = "hello world"; irange ir = make_iterator_range( str ); cout <<"print str:\n"; cout <<str<<"\n"; cout <<"iterating thru ri:\n"; range_iterator<string>::type ri(begin(ir)); for ( int i=0 ; i<2 //&& !(ri.empty()) ; ++i,++ri ) { cout <<*ri << "\n"; } return 0; }-------- cut here -------- Why doesn't range_iterator<X> have an empty method? It also seems a lot of trouble to first declare and initialize the iterator_range used as argument to range_iterator. What's the reason for not doing this directly from the iterator_range CTOR arg which could just be an stl container? I suspect I missed something, but it's not obvious, at least to me :(

Larry Evans <cppljevans <at> cox-internet.com> writes:
I suspect I missed something, but it's not obvious, at least to me :(
1. range_iterator<X> is nothing but a metafunction for an iterator. it returns an iterator type. period. So there is no i.empty() that makes sense. 2. the range lib does not have support for "for_each-style iteration". use Eric's FOREACH macro for that. br Thorsten

On 07/08/2005 09:47 AM, Thorsten Ottosen wrote:
Larry Evans <cppljevans <at> cox-internet.com> writes:
I suspect I missed something, but it's not obvious, at least to me :(
1. range_iterator<X> is nothing but a metafunction for an iterator. it returns an iterator type. period. So there is no i.empty() that makes sense.
OK. I did try using iterator_range<X>; however, that didn't have operator++; so, I'm stuck with using Torjo's rangelib. Hopefully it will be adopted into boost.
2. the range lib does not have support for "for_each-style iteration". use Eric's FOREACH macro for that.
Unfortunately, that won't work since I need the iterator to form part of another iterator, as shown in the previously mentioned fields_visitor.hpp file, where Torjo's crange is used to form part of an offset_field_iterator: http://cvs.sourceforge.net/viewcvs.py/boost-sandbox/boost-sandbox/boost/fields_visitor/fields_visitor.hpp?rev=1.4&view=auto This file shows an attempt to use the current boost::iterator_range; however, as mentioned above, there's no operator++. As you can see from looking at the code, FOREACH won't work either since, there's no operator applied to each element of the iteration, intead, each element of the iteration is used to form an element a "higher-level" iterator.
participants (2)
-
Larry Evans
-
Thorsten Ottosen