Parallelize function taking external pointers (XPtr)
问题 This question is neither a duplicate of this one nor of this one, which were about functions returning external pointers. Here's the issue. The Rcpp code hereafter defines two functions, one which creates an XPtr, and another one which can work on the XPtr. #include <Rcpp.h> using namespace Rcpp; //[[Rcpp::export]] SEXP f(int n) { std::vector<int> * v = new std::vector<int>; for(int i = 0; i < n; i++) v->push_back(i); XPtr< std::vector<int> > p(v, true); return p; } //[[Rcpp::export]] int g