在不使用 R 的情况下将 Rccp 用作 C++ STL

Using Rccp as a C++ STL without using using R

我知道 Rcpp 是一个用于 C++ 和 R 之间集成的 R 包。我有一个使用 Rcpp 的代码。但我希望直接使用 C++ 代码。是否有可能像任何普通的 C++ STL 一样获得 Rcpp,以便我可以按原样使用 Rcpp 的功能(例如:Rcpp 中的 as)?

当然可以:

R> cppFunction("double mysum(std::vector<double> x) { \
                   double s = std::accumulate(x.begin(), x.end(), 0.0); return s;}")
R> mysum(c(0.1, 0.2, 0.3))
[1] 0.6
R> 

文档中有很多 STL 示例,Rcpp Gallery and other places as e.g. my talks. Or of course the Rcpp book