fork(4) download
  1. #include <iostream>
  2. #include <map>
  3.  
  4. int main()
  5. {
  6. std::map<int, int> m { { 4, 4 } };
  7.  
  8. try
  9. {
  10. std::cout << m.at(4) << std::endl;
  11.  
  12. m.at(5);
  13. }
  14. catch (std::out_of_range const& e)
  15. {
  16. std::cout << "out_of_range: " << e.what() << std::endl;
  17. }
  18.  
  19. return 0;
  20. }
  21.  
Success #stdin #stdout 0s 3432KB
stdin
Standard input is empty
stdout
4
out_of_range: map::at