Populate a vector with all multimap values with a given key
问题 Given a multimap<A,B> M what's a neat way to create a vector<B> of all values in M with a specific key. e.g given a multimap how can I get a vector of all strings mapped to the value 123? An answer is easy, looping from lower->upper bound, but is there a neat loop-free method? 回答1: Here's the way to do it STL style : // The following define is needed for select2nd with DinkumWare STL under VC++ #define _HAS_TRADITIONAL_STL 1 #include <algorithm> #include <vector> #include <map> #include