I've tried to be better about const-ness in revision 3986. Please keep
investigating.
Thanks.
Romain
Le 16/11/12 19:53, Ramon Diaz-Uriarte a écrit :
More on const arguments:
the first will compile and work, the second will not compile, even if we
do not modify anything. As far as I can tell, in this case the culprit is
related to having the reference to the Column, because f3 does compile and
work.
I guess the problem is the "*this", returned by Column; is there another
way of making sure the caller does not modify the matrix, while enjoying
the usage of Column (and Row)?
Best,
R.
// [[Rcpp::export]]
int f1(Rcpp::IntegerMatrix m1) {
const Rcpp::IntegerMatrix::Column c1 = m1(_, 1);
int dd = c1[0] * 2;
return dd;
}
// [[Rcpp::export]]
int f2(const Rcpp::IntegerMatrix m1) {
const Rcpp::IntegerMatrix::Column c1 = m1(_, 1);
int dd = c1[0] * 2;
return dd;
}
// [[Rcpp::export]]
int f3(const Rcpp::IntegerMatrix m1) {
int dd = m1(0, 0) * 2;
return dd;
}
--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
R Graph Gallery: http://gallery.r-enthusiasts.com
`- http://bit.ly/SweN1Z : SuperStorm Sandy
blog: http://romainfrancois.blog.free.fr
|- http://bit.ly/RE6sYH : OOP with Rcpp modules
`- http://bit.ly/Thw7IK : Rcpp modules more flexible
_______________________________________________
Rcpp-devel mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel