Here’s my article from the April 2015 issue of Overload journal. It presents a simple, easy‐to‐use, generic RAII1 wrapper based on an interesting static polymorphism2 technique which I introduced in the previous post.
RAII is one of the most important and useful C++ idioms. RAII efficiently relieves the programmer of manual resource management and is a must for writing exception‐safe3 code. Perhaps, the most ubiquitous usage of RAII is dynamic memory management with smart pointers4, but there are a plenty of other resources for which it can be applied, notably in the world of low‐level libraries. Examples are Windows API handles, POSIX file descriptors, OpenGL primitives, and so on.
Also available in Russian.