fork download
  1. #include <iostream>
  2. #include <map>
  3. #include <string>
  4. #include <utility>
  5.  
  6. int main() {
  7.  
  8. std::multimap<int, std::string> mm;
  9.  
  10. mm.insert( std::make_pair(42, "message") );
  11. mm.insert( std::make_pair(100500, "hello") );
  12. mm.insert( std::make_pair(42, "string") );
  13.  
  14. for( const auto& e : mm )
  15. {
  16. std::cout << "key:" << e.first << " value:" << e.second << std::endl;
  17. }
  18.  
  19. mm.erase( 42 );
  20.  
  21. for( const auto& e : mm )
  22. {
  23. std::cout << "key:" << e.first << " value:" << e.second << std::endl;
  24. }
  25.  
  26. return 0;
  27. }
Success #stdin #stdout 0s 3476KB
stdin
Standard input is empty
stdout
key:42 value:message
key:42 value:string
key:100500 value:hello
key:100500 value:hello