fork download
  1. #include <iostream>
  2. #include <memory>
  3. #include <stdexcept>
  4.  
  5. void g() {
  6. throw std::runtime_error(std::string("Bum!"));
  7. }
  8.  
  9. void f() {
  10. try {
  11. std::unique_ptr<int> p(new int(7));
  12. std::cout << *(static_cast<int*>(p.get())) << std::endl;
  13. g();
  14. } catch(std::runtime_error &e) {
  15. std::cout << e.what() << "\n";
  16. } catch(...) {
  17. std::cout << "Случилось страшное!\n";
  18. }
  19. }
  20.  
  21. int main() {
  22. f();
  23. return 0;
  24. }
Success #stdin #stdout 0s 4436KB
stdin
Standard input is empty
stdout
7
Bum!