On Saturday, 3 March 2018 17:44:08 UTC, Chris Angelico wrote: > On Sun, Mar 4, 2018 at 4:37 AM, Richard Damon <rich...@damon-family.org> > > Yes, stack allocated object in C++ have a nice lifetime to allow RAII to > > work, but it doesn't just work with stack allocated objects. A lot of RAII > > objects are members of a class object that may well be allocated on the > > heap, and RAII makes sure that all the needed cleanup gets done when that > > object gets destroyed. > > How do you guarantee that the heap object is properly disposed of when > you're done with it? Your RAII object depends 100% on the destruction > of the heap object.
Smart pointers (unique_ptr and friends) are used to manage heap object lifecycles n . These are analogous to python object references. -- https://mail.python.org/mailman/listinfo/python-list