
6 Jun
2006
6 Jun
'06
8:45 p.m.
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& Thanks, Valentin