Showing posts with label cpp_GSL. Show all posts
Showing posts with label cpp_GSL. Show all posts
Jun 2, 2018
Sep 20, 2016
Apr 12, 2016
[reddit] [c++] List of ScopeGuard
[reddit] C++ List of ScopeGuard
[GotW.ca: Herb Sutter] Uncaught Exceptions
[cppref] std::uncaught_exceptions
[GSL] final_act allows you to ensure something gets run at the end of a scope
[GotW.ca: Herb Sutter] Uncaught Exceptions
[cppref] std::uncaught_exceptions
[GSL] final_act allows you to ensure something gets run at the end of a scope
#include <iostream>
#include <exception>
#include <stdexcept>
struct Foo {
~Foo() {
if (std::uncaught_exception()) {
std::cout << "~Foo() called during stack unwinding\n";
} else {
std::cout << "~Foo() called normally\n";
}
}
};
int main()
{
Foo f;
try {
Foo f;
std::cout << "Exception thrown\n";
throw std::runtime_error("test exception");
} catch (const std::exception& e) {
std::cout << "Exception caught: " << e.what() << '\n';
}
}
Labels:
cpp,
cpp_GSL,
cpp_ScopeGuard,
cpp11,
cpp14,
cpp17,
cpp17_exception
Sep 30, 2015
Subscribe to:
Posts (Atom)