[Rcpp-devel] Preferred idiom for obtaining a pointer in Rcpp

Douglas Bates bates at stat.wisc.edu
Tue Mar 16 01:33:00 CET 2010


I have been using the begin method to obtain a pointer to the contents
of an Rcpp::Vector object.  For example

Rcpp::NumericVector foo(10);
double *ptr = foo.begin();

Would a preferred idiom be

double *ptr = &foo[0]:

In C I would use the REAL function to obtain a pointer to the contents
of the R object.


More information about the Rcpp-devel mailing list