-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Description
Hmmm.... it looks like the answer is "sort of." The following works, but isn't totally type-safe. We could probably do a more general solution in the future. Issue?
#include "Rcpp.h"
enum DeflationMethod {
PCA = 0,
PLS = 1,
CCA = 2
};
namespace Rcpp {
SEXP wrap(DeflationMethod dm){
Rcpp::IntegerVector dm_int = Rcpp::wrap(static_cast<int>(dm));
dm_int.attr("class") = "DeflationMethod";
return dm_int;
}
template <> DeflationMethod as(SEXP dm_sexp){
Rcpp::IntegerVector dm_iv(dm_sexp);
int dm_int = dm_iv(0);
DeflationMethod dm = static_cast<DeflationMethod>(dm_int);
return dm;
}
}
// [[Rcpp::plugins(cpp11)]]
// [[Rcpp::export]]
DeflationMethod make_pls(){
DeflationMethod pls = DeflationMethod::PLS;
return pls;
}
// [[Rcpp::export]]
void take_pls(DeflationMethod x){
Rcpp::Rcout << " x = " << x << std::endl;
}
Originally posted by @michaelweylandt in #54
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels