On 8 July 2012 at 01:46, Alexandre Bujard wrote:
| Hi Joshua,
| 
| When you declare "NumericVector xx(x)" xx is a copy of the pointer x. But they
| both address the same location in the memory.

+1

| What you need here is to do a "deep copy" of the vector x. The best was to do
| that in Rcpp is to use the function "clone".

+1

Are created a few object, eg via

   NumericVector xx(x.size());   // ctor using int n of size

| Also declaring your vector xx with "const" will guarantee that your vector x
| will not be modified by the function.

That is not true, I think. C++ will make sure xx remains const, but we care
about is the memory pointed to, and that doesn't get the const protection.

Dirk
 
-- 
Dirk Eddelbuettel | [email protected] | http://dirk.eddelbuettel.com  
_______________________________________________
Rcpp-devel mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Reply via email to