[Rcpp-devel] Create an instance of a reference class for a C++ class exported as a module from within C++?

Douglas Bates bates at stat.wisc.edu
Thu Jun 2 22:31:27 CEST 2011


Sorry for the long subject line but I hope it describes what I want to
do.  I have a C++ class, dgTMatrix, that is exported in a module
definition.

RCPP_MODULE(RcppSp) {
...
    class_<dgCMatrix>("dgCMatrix")
    ...
    ;
}

Many of the methods for this class return other members of this class.
 Can I create a new instance of the reference class in R from within
the module?  I'm sure it is possible, I'm just wondering if there is
an easy way to do this without duplicating large chunks of the code in
Rcpp/src/Module.cpp.  Can i somehow clone the SEXP representing the
current instance then swap the external pointer to the C++ object?


More information about the Rcpp-devel mailing list