|
Boost : |
From: Valentin Samko (boost_at_[hidden])
Date: 2006-06-06 16:45:30
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
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk