[Rcpp-devel] Life-cycle of Rcpp::XPtr

Ralf Stubner ralf.stubner at gmail.com
Sat Sep 23 23:29:52 CEST 2023


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


More information about the Rcpp-devel mailing list