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

Ralf Stubner ralf.stubner at gmail.com
Sat Sep 23 10:28:55 CEST 2023


Hi everybody,

I have a question concerning the file-cycle of Rcpp::XPtr: Consider a
XPtr with the default delete finalizer wrapping some pointer. If I use
the copy constructor to create another XPtr, this is pointing at the
same underlying object as expected. What happens if one of these
pointers goes out of scope and is at some point garbage collected? Is
the underlying object deleted leaving the other XPtr with a broken
pointer? Or is the object protected by the existence of the other
pointer? From my experiments I have the impression that the latter is
the case, which would be the desired behaviour. But it would be nice
if one could be sure.

Thanks
Ralf


More information about the Rcpp-devel mailing list