RAII is Resource Acquisition Is Initialization, and it’s a neat concept once you
understand what it means and how it’s used. RAII was born out of C++ and invented
by its creator Bjarne Stroustrup.
In C++, the only code that can be guaranteed to be executed after an exception is
thrown are the destructors of objects residing on the stack. Resource management
needs to be tied to the lifespan of suitable objects in order to gain automatic
allocation and reclamation. Resources are acquired during initialization, and
guaranteed to be released with the destruction of the same objects.