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
_______________________________________________
Rcpp-devel mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Reply via email to