Reputation: 1475
I have a std::map<int, int>
and a std::list<std::map<int, int>::const_iterator>
.
Can I use an STL-algorithm to fill the list
with all the iterators from the map
in order?
I don't want to use an explicit loop if possible.
Upvotes: 0
Views: 566
Reputation: 60999
The algorithms in the STL call functors with values, not with iterators.
If you are obsessed with avoiding explicit loops then you might try to use iota
with an iterator as a value:
list.resize(map.size());
std::iota( std::begin(list), std::end(list), std::begin(map) );
Demo.
Upvotes: 7