-
Notifications
You must be signed in to change notification settings - Fork 53
Closed
Labels
featurea feature request or enhancementa feature request or enhancement
Description
It would be nice to have some mechanism to move enums back and forth between R and C++. I'm not sure what as_sexp() would do but as_cpp<Enum> could be:
namespace cpp11 {
template <typename E>
typename std::enable_if<std::is_enum<E>::value, E>::type as_cpp(SEXP from) {
return E(cpp11::as_cpp<typename std::underlying_type<E>::type>(from));
}
}If this is of interest, I'll polish and make it a proper pull request.
In Rcpp we had to use the RCPP_EXPOSED_ENUM_NODECL macro to declare each enum we wished to expose, manually, which sets some templates for Rcpp::as<> and Rcpp::wrap<>. IIRC, Rcpp cannot use the is_enum trait because it's a C++11 thing. https://github.com/RcppCore/Rcpp/blob/f3c5a34e06e774532227470b01c63a8f08ce4313/inst/include/Rcpp/macros/module.h#L76
Metadata
Metadata
Assignees
Labels
featurea feature request or enhancementa feature request or enhancement