[Rcpp-devel] changing a "const" argument

Ramon Diaz-Uriarte rdiaz02 at gmail.com
Fri Nov 16 15:00:12 CET 2012



Dear All,

I thought something like this would fail (would not compile):


// [[Rcpp::export]]
double changeAVector(const NumericVector a) {
  a[0] = 3.0;
  return 44.0;
}



But it does compile OK, and it really does modify the argument:

d1 <- c(93, 99); changeAVector(d1); d1


Is this expected?


Thanks,


R.

-- 
Ramon Diaz-Uriarte
Department of Biochemistry, Lab B-25
Facultad de Medicina 
Universidad Autónoma de Madrid 
Arzobispo Morcillo, 4
28029 Madrid
Spain

Phone: +34-91-497-2412

Email: rdiaz02 at gmail.com
       ramon.diaz at iib.uam.es

http://ligarto.org/rdiaz



More information about the Rcpp-devel mailing list