Is there a way to access the iterator (suppose there\'s no loop index..?) in a C++11 range-based for loop?
Often we need to do something special with the fi
Boost provides a nice succinct way to do this:
std::vector<int> xs{ 1, 2, 3, 4, 5 }; for (const auto &x : boost::make_iterator_range(xs.begin() + 1, xs.end())) { std::cout << x << " "; } // Prints: 2 3 4 5
You can find make_iterator_range in the boost/range/iterator_range.hpp header.
make_iterator_range
boost/range/iterator_range.hpp