[Rcpp-devel] Pass an Rcpp module object to a method belonging to another module from R?
Gregory Jefferis
jefferis at mrc-lmb.cam.ac.uk
Wed Sep 10 14:22:20 CEST 2014
Gregory Jefferis
On 10 Sep 2014, at 10:39, Romain Francois <romain at r-enthusiasts.com> wrote:
> RCPP_EXPOSED_CLASS(A)
>
> before you declare class A and simply use this signature for the method.
>
> void DoSomethingWithInstanceOfA(const A& )
I used this approach happily in the nabor package (on github) but the only caveat is that from R you need to call with something like:
A$method(B$.CppObject)
You can get some interesting crashes if you pass the R reference class (i.e. B) directly as the argument. I guess it might be better to have a derived R class that looks after extracting the .CppObject field.
Best,
Greg.
More information about the Rcpp-devel
mailing list