Rcpp 公开类的序列化

Min*_*dge 5 c++ serialization r rcpp

RCPP_EXPOSED_CLASS我在 R 包中编写了一个 C++ 类,并使用和向 R 命名空间公开了该类RCPP_MODULE

一切都很好:

> index
An object of class "Index"
Slot "index":
C++ object <0x9cd4810> of class 'DB' <0xfd66220>
Run Code Online (Sandbox Code Playgroud)

但如果saveRDS(index, 'DB.rds')它不保存实际对象,只保存地址。反过来,当我DB.rds在新会话中加载时,它会被强制转换为无效。

是否可以编写一个可以透明地工作的自定义序列化方法saveRDS