[R-pkg-devel] Virtual C++ functions

Iñaki Ucar |uc@r @end|ng |rom |edor@project@org
Wed Nov 15 15:29:35 CET 2023


On Wed, 15 Nov 2023 at 12:45, Michael Meyer via R-package-devel
<r-package-devel using r-project.org> wrote:
>
> Greetings,
> Suppose I wanted to develop a package with C++ code that contains virtual functions which the package user should define.It's assumed that evaluation is expensive so we do not want to define these in R and then call these R-functions from C++.
> Is this a reasonable idea with a standard solution?Are there packages that do this?
> Thanks in advance for all answers,

Not sure if I understand what you are after, but the small
RcppXPtrUtils package may be helpful. It provides two things: a
utility to compile and wrap a C++ function provided by the user, and
another one to check that the signature is correct. See:
https://gallery.rcpp.org/articles/passing-cpp-function-pointers-rcppxptrutils/

-- 
Iñaki Úcar



More information about the R-package-devel mailing list