fork(1) download
  1. #include <map>
  2. #include <string>
  3. #include <iostream>
  4. int main()
  5. {
  6. std::map<int, std::string> myMap =
  7. {{ 1, "One"},
  8. {2, "Two"},
  9. {3, "Three"},
  10. {7, "Seven"}};
  11. myMap.erase(myMap.begin());
  12.  
  13. auto i = myMap.upper_bound(4);
  14. std::cout << (--i)->second << '\n';
  15. std::cout << myMap.size() << '\n';
  16.  
  17. }
Success #stdin #stdout 0.01s 5272KB
stdin
Standard input is empty
stdout
Three
3