Dear all,

while writing an iterator hack for the problem encountered a few hours ago
and posted here:

https://www.mail-archive.com/rcpp-devel@lists.r-forge.r-project.org/msg06810.html,

I have noticed that the default behavior for the range constructor for e.g.
Rcpp::NumericVector seems to be to allocate fresh memory:

arma::mat obj1(5, 10, arma::fill::zeros);
Rcpp::NumericVector obj2(obj1.begin(), obj1.begin() + 5);
obj2 = 1.;
Rprintf("obj1: %f, obj2: %f\n", obj1(0,0), obj2(0));

yields that obj1 and obj2 differ.

Is there any way to tell the range constructor to reuse existing memory
similarly to the (Rcpp)Armadillo feature copy_aux_mem = false or am I
missing something more subtle?

Thanks in advance for any hints,
Gregor
_______________________________________________
Rcpp-devel mailing list
Rcpp-devel@lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Reply via email to