fork download
  1. #include <iostream>
  2. #include <iterator>
  3. #include <vector>
  4. #include <unordered_map>
  5. #include <algorithm>
  6.  
  7. int main() {
  8. std::vector<int> v;
  9. typedef std::unordered_multimap<int, int> MapType;
  10.  
  11. MapType m { { 1, 1 }, { 1, 2 }, { 2, 1 }, { 2, 2 }, { 3, 1 } };
  12. std::for_each(begin(m), end(m), [&](MapType::value_type i){v.push_back(i.second); });
  13. std::copy(begin(v), end(v), std::ostream_iterator<int>(std::cout, " "));
  14.  
  15. return 0;
  16. }
Success #stdin #stdout 0s 3432KB
stdin
Standard input is empty
stdout
1 2 1 2 1