4 ms·
It only works with stack variables, but you can wrap the construction and destruction of anything, including heap-allocated objects, with a stack variable. You
by altano 17y ago
It only works with stack variables, but you can wrap the construction and destruction of anything, including heap-allocated objects, with a stack variable. You tie the allocation of the heap object to the constructor of the stack variable, and the reverse for de-allocation/destructor.
The premise of all this is that the construction and destruction of stack variables both happen at well known times and are guaranteed to occur.