[Rcpp-devel] shallow/deep copy
Christian Gunning
xian at unm.edu
Wed Aug 31 13:05:59 CEST 2011
On Wed, Aug 31, 2011 at 3:00 AM,
<rcpp-devel-request at r-forge.wu-wien.ac.at> wrote:
>
> Rcpp::NumericVector x = as<Rcpp::NumericVector>(x_);
> std::vector<double> x = as< std::vector<double> >(x_);
Nice clarification of what's going on under the hood, Darren.
For the first case, the above is synonymous with:
Rcpp::NumericVector x(x_);
If you want a deep copy, you can use:
Rcpp::NumericVector x(clone(x_));
See the quickref pdf for examples
(http://cran.r-project.org/web/packages/Rcpp/vignettes/Rcpp-quickref.pdf)....
there, "using namespace Rcpp;" is implied throughout unless otherwise
noted.
-xian
--
A man, a plan, a cat, a ham, a yak, a yam, a hat, a canal – Panama!
More information about the Rcpp-devel
mailing list