[Rcpp-devel] Ease passing pointers
On Tue, Dec 31, 2013 at 3:10 PM, Dirk Eddelbuettel <edd at debian.org> wrote:
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
A little obscure indeed. I got a little lost in the documentation and was looking for a shortcut. I think I need to specialize "wrap" and "as". THK
Timothy H. Keitt http://www.keittlab.org/ -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20131231/700daf96/attachment.html>