Currently, something like this is allowed with no problems:
SEXP rray__exp_impl(const xt::rarray<rlogical>& x) {
xt::rarray<double> res = xt::exp(x);
return res;
}
The (potentially safer) approach would be to return an Rcpp::RObject like this:
Rcpp::RObject rray__exp_impl(const xt::rarray<rlogical>& x) {
xt::rarray<double> res = xt::exp(x);
return res;
}
But this gives me a "no viable conversion" error as it does not know how to convert to RObject from xt::rarray<double>. I can do something like this, but it is just a bit annoying:
Rcpp::RObject rray__exp_impl(const xt::rarray<rlogical>& x) {
xt::rarray<double> res = xt::exp(x);
return Rcpp::as<Rcpp::RObject>(res);
}
Do you know if its possible to add this implicit conversion?
PS: If you not aware, RObjects are wrappers around SEXPs that Rcpp added that help automatically manage the underlying storage properties (they are also the base class that all core Rcpp classes inherit from). So you don't have to call PROTECT() and UNPROTECT() like you would have to do on the raw R SEXP objects
Currently, something like this is allowed with no problems:
The (potentially safer) approach would be to return an
Rcpp::RObjectlike this:But this gives me a "no viable conversion" error as it does not know how to convert to
RObjectfromxt::rarray<double>. I can do something like this, but it is just a bit annoying:Do you know if its possible to add this implicit conversion?
PS: If you not aware,
RObjects are wrappers aroundSEXPs that Rcpp added that help automatically manage the underlying storage properties (they are also the base class that all core Rcpp classes inherit from). So you don't have to callPROTECT()andUNPROTECT()like you would have to do on the raw RSEXPobjects