fork(7) download
  1. #include <iostream>
  2. #include <string>
  3. #include <stdexcept>
  4.  
  5. void foo()
  6. {
  7. auto func = [] (std::string msg) [[noreturn]] { throw std::runtime_error(msg); };
  8. return func("Test Message");
  9. }
  10.  
  11. int main()
  12. {
  13. try
  14. {
  15. foo();
  16. }
  17. catch (...)
  18. {
  19. std::cout << "Caught the exception.\n";
  20. }
  21. }
  22.  
Success #stdin #stdout 0s 3456KB
stdin
Standard input is empty
stdout
Caught the exception.