Overload journal #126, April 2015

Resource Management with Explicit Template Specialisations

Metadata

A clock. Published:
.
A newspaper. Reading time:
.

Here’s my article from the April 2015 issue of Overload journal. It presents a simple, easy‐to‐use, generic RAII wrapper based on an interesting static polymorphism1 technique which I introduced in the previous post.

Resource Management with Explicit Template Specialisations

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‐safe code. Perhaps, the most ubiquitous usage of RAII is dynamic memory management with smart pointers, 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.


Footnotes

  1. A form of polymorphism in programming code which is resolved at compile time (i.e. without dynamic dispatch overhead).