by Paul_Diraq · 7y ago · 0 comments
For the rare cases that you need finalizers which might throw I would go for something inspired by pythons with statement.
WITH(expr , lambda)
expands to(sketch): bool _exception_happened=false;
auto __temp = expr;
__temp.enter();
try{
lambda(__temp)
}catch(const std::exception & ex){
exception_happened = true;
__temp.exit(ex);
}
if (not exception_happened){
__temp.exit();
}No comments yet.