I would like to call a template function including the expression
T::get_na() with a matrix Column as the T. The toy program below
illustrates what I am trying to do.

Various error messages are generated by the compiler with, I think, the key
one being:

column_get_na.cpp:11:2: error: 'get_na' is not a member of
'Rcpp::MatrixColumn<13>'

Is it deliberate that get_na is not a member of Column? If so, what is the
appropriate workaround in the context of calling a template function? In
not, any plans to implement Column::get_na()?

Thanks.

Toy program:

#include <Rcpp.h>
using namespace Rcpp;
template<typename T>
T set1na_vec(T vec) {
vec[0] = T::get_na();
return vec;
}
// [[Rcpp::export]]
IntegerMatrix set1na_mat(IntegerMatrix mat) {
IntegerMatrix::Column col = mat(_, 0);
set1na_vec(col);
return mat;
}
/***R
mat = matrix(1:10, ncol=2)
set1na_mat(mat)
*/
_______________________________________________
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