[Rcpp-devel] [Rcpp Modules] Static functions

Romain Francois romain at r-enthusiasts.com
Thu May 9 18:24:37 CEST 2013


This is not supported currently. It might be in the future when someone finds time or funding. 

One thing that could be done is to create a simple wrapper function around it and expose this with the module. You wont get the associarion with the class though. 

double wrapper_myFunction(){
    return Foo::myFunction() ;
}

We might support direct syntactic sugar for exposing static functions later, but i'm not sure the concept of staric functions is supported by reference classes which is the texhnology we use to expose module classes. 

Romain

Le 9 mai 2013 à 16:47, Julien Duvanel <julien.duvanel at epfl.ch> a écrit :

> Hello,
> 
> First of all, thanks for all the Rcpp*. It's very helpful.
> 
> I have a small question, and I can't (unfortunately) find the answer over the internet. I'm trying to do this :
> 
> class Foo {
> 	public:
> 		double static myFunction();
> };
> 
> And then, use the RCPP_MODULE :
> 
> RCPP_MODULE(mod_Foo) {
> 	class_<Foo>("Foo")
> 
> 	.method("myFunction", &Foo::MyFunction", "bla bla bla")
> }
> 
> Unfortunately, it doesn't compile and gives me the following error :
> 
> integration.h:82: error: no matching function for call to ‘Rcpp::class_<NewModel>::method(const char [12], Rcpp::NumericVector (*)(Rcpp::NumericVector, Rcpp::NumericVector, double, double, double, double, int), const char [37])’
> 
> Maybe it just works as intended, but I haven't found anything inside the documentation. (It works when I remove the static). Has anybody an idea ?
> 
> Thank you very much and have a nice day,
> 
> Julien
> _______________________________________________
> Rcpp-devel mailing list
> Rcpp-devel at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20130509/90a41333/attachment.html>


More information about the Rcpp-devel mailing list