October 14, 2012 D-style scope(failure) and scope(success) in C++ | ||||
|---|---|---|---|---|
| ||||
try
{
int some_var=1;
cout << "Case #1: stack unwinding" << endl;
scope(exit)
{
cout << "exit " << some_var << endl;
++some_var;
};
scope(failure)
{
cout << "failure " << some_var << endl;
++some_var;
};
scope(success)
{
cout << "success " << some_var << endl;
++some_var;
};
throw 1;
} catch(int){}
https://github.com/panaseleus/stack_unwinding#d-style-scope-guardsactions
https://github.com/panaseleus/stack_unwinding/blob/master/examples/example_from_dlang_dot_org.cpp
https://github.com/panaseleus/stack_unwinding/blob/master/examples/boost_scopes.cpp
https://github.com/panaseleus/stack_unwinding/blob/master/examples/boost_scopes_cpp11.cpp
| ||||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply