Boost logo

Boost :

From: Thorsten Ottosen (thorsten.ottosen_at_[hidden])
Date: 2006-06-06 18:35:19


Valentin Samko wrote:
> Is it intentional that one can not call range.front() on an iterator
> range of const values?
>
> #include <boost/range/iterator_range.hpp>
> int main() {
> typedef const char* iterator;
> iterator p = "test";
> boost::iterator_range<iterator> range(p, p+1);
> range.front();
> }
>
> This fails to compile as
> value_type& front() const { ... return *m_Begin; }
> in iterator_range.hpp
> tries to bind a const char lvalue to a non const reference.
>
> The same happens with back() and operator[].
>
> The fix is to return
> typename std::iterator_traits<IteratorT>::reference
> and not
> value_type&

I believe this is fixed in cvs and rc_1.34 branch.

-Thorsten


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