On Sun, Mar 4, 2018 at 1:01 PM, Ooomzay <ooom...@gmail.com> wrote:
> 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.

Yep, cool. Now do that with all of your smart pointers being on the
heap too. You are not allowed to use ANY stack objects.  ANY. Got it?

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to