[Rcpp-devel] Method with default params using RCPP_MODULE

Sergio Bra sergio.bra88 at gmail.com
Wed Oct 26 09:48:04 CEST 2016


I am exposing a c++ class using Rcpp. It works fantastic, but my problem is
how to implement a method which has default params. I have the class:

class myClass {

    public:

        int myMethod(int param1, int param2 = 0);
}

and I config the module:

RCPP_MODULE(mymodule) {
    class_<myClass>("myClass")
        .constructor()
        .method("myMethod", &myClass::myMethod)
;
}

When I try to execute the function in R passing only the mandatory param I
get an error because R does not recognize the function, but if I execute it
with both params, it works great. So, how can I define the method in order
to be able to execute it without informing the optional params?

Thank you,

Sergio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20161026/630481dc/attachment.html>


More information about the Rcpp-devel mailing list