fork(1) download
  1. #include <iostream>
  2. #include <map>
  3.  
  4. namespace std
  5. {
  6. template<typename Iter, typename = typename iterator_traits<Iter>::iterator_category>
  7. Iter begin(pair<Iter, Iter> const &p)
  8. {
  9. return p.first;
  10. }
  11. template<typename Iter, typename = typename iterator_traits<Iter>::iterator_category>
  12. Iter end(pair<Iter, Iter> const &p)
  13. {
  14. return p.second;
  15. }
  16. }
  17.  
  18. int main()
  19. {
  20. std::multimap<int, int> mm
  21. {
  22. {1, 1},
  23. {1, 2},
  24. {2, 1},
  25. {2, 2}
  26. };
  27. for(auto &v : mm.equal_range(1))
  28. {
  29. std::cout << v.first << " -> " << v.second << std::endl;
  30. }
  31. }
  32.  
Success #stdin #stdout 0s 3428KB
stdin
Standard input is empty
stdout
1 -> 1
1 -> 2