[Rcpp-devel] T::get_na() where T is a Column

Rguy rguy at 123mail.org
Fri Sep 11 09:53:34 CEST 2015


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)
*/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20150911/3bf4a597/attachment.html>


More information about the Rcpp-devel mailing list