The C++11 range-based for loop dereferences the iterator. Does that mean that it makes no sense to use it with boost::adaptors::indexed
? Example:
boost::counting_range numbers(10,20);
for(auto i : numbers | indexed(0)) {
cout << "number = " i
/* << " | index = " << i.index() */ // i is an integer!
<< "\n";
}
I can always use a counter but I like indexed iterators.
- Is it possible to use them somehow with range-based for loops?
- What is the idiom for using range-based loops with an index? (just a plain counter?)
indexed
sucks because it adds theindex()
method to the iterator, not the value returned from dereferencing the iterator. :/ – Auleavalue_type
withindex()
andvalue()
member functions. – Demimondaineboost::adaptor::indexed
toboost::adaptors::indexed
, as it took a while for me to realize thats
was missing? – Cusped