Of course, the as<>() converter does this.
It can be called explicitly (which you need here), sometimes called an implicit compiler, or even inserted using code generation helpers as follows:
R> cppFunction('int twiceTheValue(int a) { return 2*a; }') R> twiceTheValue(21) [1] 42 R>
If you call cppFunction() (and related functions from the Rcpp attributes or inline package) with the verbose=TRUE argument, you see the generated code.
Here i get
and our documentation explains what the BEGIN_RCPP , END_RCPP macros do, why there is an RNGScope object, and you see as<>() and wrap() that you need.
source share