Does ScopeGuard use really lead to better code?

It definitely improves your code. Your tentatively formulated claim, that it’s obscure and that code would merit from a catch block is simply not true in C++ because RAII is an established idiom. Resource handling in C++ is done by resource acquisition and garbage collection is done by implicit destructor calls. On the other hand, … Read more

The simplest and neatest c++11 ScopeGuard

Even shorter: I don’t know why you guys insist on putting the template on the guard class. #include <functional> class scope_guard { public: template<class Callable> scope_guard(Callable && undo_func) try : f(std::forward<Callable>(undo_func)) { } catch(…) { undo_func(); throw; } scope_guard(scope_guard && other) : f(std::move(other.f)) { other.f = nullptr; } ~scope_guard() { if(f) f(); // must not … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)