Boost logo

Boost :

From: Thorsten Ottosen (nesotto_at_[hidden])
Date: 2005-08-17 16:27:05


"Larry Evans" <cppljevans_at_[hidden]> wrote in message
news:ddvtch$6pv$1_at_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


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