[Rcpp-devel] Rcpp and ExternalPtr

JJ Allaire jj.allaire at gmail.com
Fri Dec 5 11:37:03 CET 2014


I think the XPtr class is what you are looking for:

http://www.r-bloggers.com/external-pointers-with-rcpp/


On Fri, Dec 5, 2014 at 2:45 AM, Jeroen Ooms <jeroen.ooms at stat.ucla.edu> wrote:
> Does Rcpp provide some elegant way to let the R user manage persistent
> c++ objects that have no R type (e.g. internal handles or sessions of
> some sort)?
>
> In C, I would use R_MakeExternalPtr to create a ptr SEXP that the user
> can pass from one R function to another. This also makes it easy to
> add a finalizer with R_RegisterCFinalizerEx so that the garbage
> collector will automatically clean up the session/handle whenever user
> deletes the R object.
>
> Most Rcpp examples I have seen use function arguments with standard
> data types that are automatically mapped to R types. Does Rcpp have
> any special mechanics for managing external objects (pointers) from R
> which do not map to a SEXP type? Or do I have to fall back on
> Rinternals for this?
> _______________________________________________
> Rcpp-devel mailing list
> Rcpp-devel at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel


More information about the Rcpp-devel mailing list