Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
I have a std::map<int, int> and a std::list<std::map<int, int>::const_iterator>.
std::map<int, int>
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.
list
map
std::copy()
std::list<map<int, int>::iterator>
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:
iota
list.resize(map.size()); std::iota( std::begin(list), std::end(list), std::begin(map) );
Demo.
Add a comment
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.
std::copy()uses a loop.std::list<map<int, int>::iterator>? This sounds highly suspect to me.