[Rcpp-devel] Modify R object within C++ function that returns bool to indicate success/failure
Paul Theodor Pyl
pyl at embl.de
Thu Jul 1 14:24:45 CEST 2010
Hi all,
I have a question concerning the modification of R objects within C++
using Rcpp, what I would like to do is shown in this fantasy-R-session:
> l <- list()
> while( mycppfunc( l ) ){ print("running!") }
running!
running!
...
> l
$a
[1] "Something"
$b
...
The corresponding c++ function would look like this:
bool mycppfunc( List l ){
some_struct x;
if( some_other_function( x ) ){
l[x.name] = x.some_member;
return true;
}else{
return false;
}
}
where some_other_function is a c++ function that takes the struct and
modifies it returning a bool to indicate success/failure.
Looking at the examples of Rcpp so far I have not found one where an R
object is handed to a c++ function that modifies it and returns a bool
to indicate success / failure.
How would I go about this? Could that be done using SEXP's (since they
are pointers I would suspect they can be modified 'in-place')
Cheers,
Paul
More information about the Rcpp-devel
mailing list