[Rcpp-devel] shallow/deep copy

Zhongyi Yuan yuanzygoso at gmail.com
Wed Aug 31 07:52:22 CEST 2011


Hello everyone,

I am testing my code and find something that I hope someone can conform for
me. Thanks in advance. It seems to me that

NumericVector x = as<NumericVector>(x_); ( Btw, this is exactly the same as
NumericVector x(x_), both resulting in a shallow copy, isn't it? ) produces
a shallow copy, while
vector<double> x = as< vector<double> >(x_); produces a deep copy.

Is it because for NumvericVector the as() function returns the address of
x_? But why does it work differently for vector<double>?

Thank you for your answer.

Best,
Zhongyi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20110831/60e0d0c8/attachment.htm>


More information about the Rcpp-devel mailing list