[Rcpp-devel] Ease passing pointers

Dirk Eddelbuettel edd at debian.org
Tue Dec 31 22:10:32 CET 2013


On 31 December 2013 at 14:16, Tim Keitt wrote:
| Can the following be simplified?
| 
| (Typed in email, so not live code.)
| 
| // [[Rcpp::export]]
| void func(SEXP x)
| {
|   XPtr<aType> y(x);
|   func2(&*y);
|   y->memfunc();
| }
| 
| Is there a way to avoid the need to construct the XPtr in the 1st line? Hoping
| for:
| 
| // [[Rcpp::export]]
| void func(aType* x)
| {
|   func2(x);
|   x->memfunc();
| }

We don't know what func2() is, or what it's signature is. Ditto for y. 

In general, we go the route of using XPtr if we need to get the pointer back
to R, maybe because our R logic then dispatches it somewhere else.

Your examples are admiringly short, which is very good. They are also
incomplete and a little incomprehensible which is less good :)

Cheers, Dirk

-- 
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com


More information about the Rcpp-devel mailing list