Message-ID: <CAFQwRQwNPhbXsXhbVmrwA0DLFfaTzoPTaeiZx=b-BiVEOj2vqA@mail.gmail.com>
Date: 2023-09-23T21:29:52Z
From: Ralf Stubner
Subject: [Rcpp-devel] Life-cycle of Rcpp::XPtr
In-Reply-To: <393CAD69-AC6E-4E07-BE43-8AFA997C6EDC@R-project.org>
On Sat, Sep 23, 2023 at 9:49?AM Simon Urbanek
<simon.urbanek at r-project.org> wrote:
>
> The copy constructor doesn't actually create a copy, it only acts as a wrapper that preserves the same EXTPTR object, it is akin to increasing the reference count, so the C++ class wrapped in the EXTPTR is only released when the EXTPTR can be garbage-collected, i.e. all references are gone (including all "copies").
> [Of course that is not true if you were to create two XPtrs with the same pointer and a finalizer each, but that would be a bad idea, obviously].
Thanks Simon! This seems to be the behaviour I am looking for.
Ralf