expose class in Rcpp - factory instead of constructor

萝らか妹 提交于 2019-12-06 04:48:41

You can use .factory for registering a free function as a constructor to your class, but in that case the function should return a pointer to a CEC. Something like this:

CEC* CEC__new(SEXP args);

RCPP_MODULE(cec) {
  using namespace Rcpp;
  class_<CEC>("cec")   
    .factory( CEC__new )
    .method("test", &CEC::test)
    .method("loop", &CEC::loop)
    .method("singleLoop", &CEC::singleLoop)
    .method("entropy", &CEC::entropy)
    ;
}

Or perhaps:

   .factory<SEXP>( CEC__new )
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!