3 ms·
All of these can be done in a class's destructor, which is called when the object is deleted, e.g. when a shared_ptr's ref-count reaches 0 (i.e. there are no re
by mkl 15y ago
All of these can be done in a class's destructor, which is called when the object is deleted, e.g. when a shared_ptr's ref-count reaches 0 (i.e. there are no references to it left). To express observation (and break cycles) there is weak_ptr, and to express ownership there is unique_ptr.
IMO the new pointer stuff is excellent, and relieves the large majority of the memory management burden.
- reddit_clone 15y agoThere are some boost macros which will run clean up code at the end of the scope if you prefer. They are not pretty. But they work. (This is a life saver in a long function with multiple exit points)