Created
September 6, 2015 00:17
-
-
Save LB--/113d4f6616d1a57470dc to your computer and use it in GitHub Desktop.
C++ supports multiple active exceptions at once - see it in action at http://melpon.org/wandbox/permlink/PscHg988AnzjajyS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <stdexcept> | |
#include <exception> | |
struct ResonanceCascade final | |
{ | |
ResonanceCascade() | |
{ | |
std::cout << "ResonanceCascade ctor" << std::endl; | |
} | |
~ResonanceCascade() noexcept(false) | |
{ | |
std::cout << "~ResonanceCascade() begin" << std::endl; | |
std::cout << "std::uncaught_exceptions() == " << std::uncaught_exceptions() << std::endl; | |
try | |
{ | |
if(std::uncaught_exceptions() < 5) | |
{ | |
ResonanceCascade rc; | |
throw std::logic_error{"Black Mesa"}; | |
} | |
} | |
catch(...) | |
{ | |
std::cout << "~ResonanceCascade() catch" << std::endl; | |
} | |
std::cout << "~ResonanceCascade() end" << std::endl; | |
} | |
}; | |
int main() | |
{ | |
try | |
{ | |
ResonanceCascade rc; | |
throw std::logic_error{"Black Mesa"}; | |
} | |
catch(...) | |
{ | |
std::cout << "main catch" << std::endl; | |
} | |
} |
Author
LB--
commented
Sep 6, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment