RCPP Extending
RCPP Extending
This note provides an overview of the steps programmers should follow to The Rcpp converter functions Rcpp::as and Rcpp::wrap are
extend Rcpp (Eddelbuettel et al., 2022; Eddelbuettel and François, 2011) extensible to user-defined types and third-party types.
for use with their own classes. This document is based on our experience
in extending Rcpp to work with the Armadillo (Sanderson, 2010) classes,
2. Extending Rcpp::wrap
available in the separate package RcppArmadillo (Eddelbuettel et al., 2021).
This document assumes knowledge of Rcpp as well as some knowledge of The Rcpp::wrap converter is extensible in essentially two ways :
C++ templates (Abrahams and Gurtovoy, 2004). intrusive and non-intrusive.
4. Summary
The Rcpp package greatly facilitates the transfer of objects between
R and C++. This note has shown how to extend Rcpp to either user-
defined or third-party classes via the Rcpp::as and Rcpp::wrap
template functions. Both intrusive and non-intrusive approaches
were discussed.
References
Abrahams D, Gurtovoy A (2004). C++ Template Metaprogramming: Concepts,
Tools and Techniques from Boost and Beyond. Addison-Wesley, Boston.
Eddelbuettel D, François R (2011). “Rcpp: Seamless R and C++
Integration.” Journal of Statistical Software, 40(8), 1–18. doi:
10.18637/jss.v040.i08. URL https://doi.org/10.18637/jss.v040.i08.
Eddelbuettel D, François R, Allaire J, Ushey K, Kou Q, Russel N, Chambers J,
Bates D (2022). Rcpp: Seamless R and C++ Integration. R package version
1.0.8, URL https://CRAN.R-Project.org/package=Rcpp.
Eddelbuettel D, François R, Bates D, Ni B (2021). RcppArmadillo: Rcpp in-
tegration for Armadillo templated linear algebra library. R package version
0.10.7.5.0, URL https://CRAN.R-Project.org/package=RcppArmadillo.
Sanderson C (2010). “Armadillo: An open source C++ Algebra Library for Fast
Prototyping and Computationally Intensive Experiments.” Technical report,
NICTA. URL https://arma.sf.net.