[range]possible error in iterator_range<range_result_iterator<const Container>::type >

The following code: <======================== template < class Container
void test_iter_range(Container& a_cont) { typedef typename range_result_iterator<Container>::type citer_type; typedef iterator_range<citer_type> riter_type; riter_type a_riter(a_cont.begin(),a_cont.end()); std::cout<<"a_riter.front="<<a_riter.front()<<"\n"; }
========================= Gives compile time error when Container is const. See test driver and compiler output in sandbox vault under cppljevans and in file iter_range_test.zip.
Is this an error in the range lib or am I doing something wrong? TIA. -regards, Larry

"Larry Evans" <cppljevans@cox-internet.com> wrote in message news:ddvtch$6pv$1@sea.gmane.org...
The following code: <======================== template < class Container
void test_iter_range(Container& a_cont) { typedef typename range_result_iterator<Container>::type citer_type; typedef iterator_range<citer_type> riter_type; riter_type a_riter(a_cont.begin(),a_cont.end()); std::cout<<"a_riter.front="<<a_riter.front()<<"\n"; }
========================= Gives compile time error when Container is const.
indeed.
Is this an error in the range lib or am I doing something wrong?
The problem is that front() specifies its return-type as iterator_value<Iter>::type which is the same for both iterator and const_iterator. I think we need range_reference<T>::type to solve this dilemma. The reference should correctly track the constness. Thanks for spotting this. -Thorsten
participants (2)
-
Larry Evans
-
Thorsten Ottosen