Advertisement
Guest User

Untitled

a guest
Apr 16th, 2014
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. #include <iostream>
  2. #include <exception>
  3.  
  4. namespace{
  5. struct foo{
  6. void change_state() noexcept
  7. {
  8. // change state and fail
  9. throw std::exception();
  10. }
  11. ~foo(){
  12. std::cout << "Destructor called, saved state corrupted!" <<std::endl;
  13. }
  14. };
  15. }
  16.  
  17.  
  18. int main(){
  19. ::std::set_terminate([](){
  20. std::cout<< "Terminate called" <<std::endl;
  21. });
  22.  
  23. foo f;
  24. f.change_state();
  25. return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement