Search code examples
c++scopeguard

Where can I find a good Scope Guard implementation for my C++ projects?


I just recently learned about Scope Guard C++ idiom. Unfortunately I can't find any good implementation of it.

Can anyone point me to some good and usable Scope Guard implementation in C++?

Thanks, Boda Cydo.


Solution

  • ScopeGuard has been included in the Loki library (advertised in Modern C++ Design by Andrei Alexandrescu, I'm sure you've heard of this great book), and is mature enough to be used in production code, imo.

    Just to be clear: We're talking about writing exception safe code using RAII.

    Additional reading (on StackOverflow): Does ScopeGuard use really lead to better code?