Range-based for loop with boost::adaptor::indexed
This was fixed in Boost 1.56 (released August 2014); the element is indirected behind a value_type
with index()
and value()
member functions.
Example: http://coliru.stacked-crooked.com/a/e95bdff0a9d371ea
auto numbers = boost::counting_range(10, 20);
for (auto i : numbers | boost::adaptors::indexed())
std::cout << "number = " << i.value()
<< " | index = " << i.index() << "\n";