fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <typeinfo>
  4. #include <stdexcept>
  5.  
  6. class ExceptionHandler
  7. {
  8. public:
  9. static std::string get_exception_type_name(std::exception const& ex)
  10. {
  11. return typeid(ex).name();
  12. }
  13. };
  14.  
  15. int main()
  16. {
  17. std::string any = "any";
  18. std::out_of_range ex("Out of range exception");
  19.  
  20. std::cout << ExceptionHandler::get_exception_type_name(ex) << std::endl;
  21. }
  22.  
Success #stdin #stdout 0s 2984KB
stdin
Standard input is empty
stdout
St12out_of_range