[Rcpp-devel] can one modify array in R memory from C++ without copying it?

Darren Cook darren at dcook.org
Fri Nov 4 08:01:34 CET 2011


> I.e. the point of his code was to show that a matrix of doubles gets
> modified, a matrix of ints does not.

Or change the first line from NumericMatrix to:
   Rcpp::IntegerMatrix r_m(mem);

Then the behaviour is reversed. The matrix of doubles does not get
modified, but the matrix of ints does!

Dirk, Romain, this is a bug-in-waiting. Is there any way to generate a
warning when the implicit deep copy happens? Or alternatively when the
pointer is being used implicitly... but my hunch is that I want to know
when there is any implicit conversion between int and double: modern C++
style is to explicitly declare all type conversions with static_cast<>
and friends.

Darren


More information about the Rcpp-devel mailing list