
Neal Becker wrote:
STL iterators are designed so that ordinary pointers can be iterators. Can we do the same with boost::range?
With STL we can do: int x; std::copy (&x, &x+1, output);
Does this work for range?
#include <boost/range.hpp>
template<typename in_t> void F (in_t const& in) { typename boost::range_const_iterator<in_t>::type i = boost::begin (in); for (; i != boost::end (in); ++i) ; }
int main() { int x; F (boost::sub_range<int*> (&x, &x+1)); }
usr/local/src/boost.cvs/boost/range/sub_range.hpp:26: instantiated from ‘boost::sub_range<int*>’ test.cc:11: instantiated from here /usr/local/src/boost.cvs/boost/range/mutable_iterator.hpp:37: error: ‘int*’ is not a class, struct, or union type
How do I turn the 'int x' into a 'range'?
That is certainly an interesting question. By default, T* is not a Range. It's an iterator: int x; F( make_iterator_range(&x, &x+1) ); -Thorsten