3 ms·
The A in RAII is for acquisition and it is about ownership, not allocation. You can do exactly those things in C++ (operator new or allocators, T::T(), T::~T()
by gpderetta 8y ago
The A in RAII is for acquisition and it is about ownership, not allocation.
You can do exactly those things in C++ (operator new or allocators, T::T(), T::~T(), operator delete). The language just gives the tools to distinguish a bunch of uninitialized memory from an actual T which holds its invariant (if any).
- jstimpfle 8y agoOk acquisition it is. I don't even understand the difference. Wikipedia doesn't seem to make a distinction either. Uninitialized memory is all I ever want. And I want to simply write to that memory when the time has come, not hide those writes in a T::T() somewhere in an isolated file with lots of braces and spaces and colons and only few things that actually happen. It's really hard to map out the codepath of a project with lots of constructors and inherited constructors 15 levels down the call stack. Same applies for running it in a debugger.