In C++, does RAII imply that a stack object (an object allocated on a stack, e.g. a local variable in a function) is deallocated only when execution gets out of the scope of the stack object?
What if I would like to deallocate a stack object a little bit before execution reaches the end of the scope of the stack object?
Thanks.
It sounds like you want
std::optional
. It allows automatic resource management, but also allows a "deallocated" state.