
Shunsuke Sogame wrote:
Hi gurus, under RC_1_34,
#include <boost/range.hpp> #include <boost/iterator/counting_iterator.hpp>
int main() { boost::make_iterator_range( boost::make_counting_iterator(0), boost::make_counting_iterator(5) )[2]; }
VC++7.1 and GCC3.4 says a warning something like "returning address of local variable or temporary".
I think counting_iterator is not a valid random access iterator because operator[]() does not yield a reference.
counting_iterator is implemented by iterator_facade, whose operator[] returns *value*. In fact, the result type of iterator_facade's operator[] seems unspecified. Is it possible to do forwarding of iterator's operator[], which is tried by iterator_range?
Counting iterator should define its reference-type to be the type it returns from operator[]() (even though it is not a reference). Then I think it would work. Do the authors of the iterator lib agree? -Thorsten