[Rcpp-devel] package contains overloaded methods in module
Chaomei Lo
chaomeilo at gmail.com
Wed Jul 2 08:29:38 CEST 2014
I use Romain's example as follows (after /// line). It works fine with the
sourceCpp(..). However, with the package I created, it loaded fine but I
got this error below when I instantiate the class. -Thanks for help.
> library("testModule", lib.loc="/people/me/.Rlibs")
> r <- new( Randomizer )
Error in .getClassFromCache(Class, where) : object 'Randomizer' not found
////////////////////////////////////////////////////////
#include <Rcpp.h>
using namespace Rcpp;
class Randomizer {
public:
Randomizer(){}
NumericVector get( int n ){
RNGScope scope ;
return runif( n, 0.0, 1.0 );
}
NumericVector get( int n, double min ){
RNGScope scope ;
return runif( n, min, 1.0 );
}
NumericVector get( int n, double min, double max ){
RNGScope scope ;
return runif( n, min, max );
}
} ;
RCPP_MODULE(mod){
// helping the compiler disambiguate things
NumericVector (Randomizer::*get_1)(int) = &Randomizer::get ;
NumericVector (Randomizer::*get_2)(int,double) = &Randomizer::get ;
NumericVector (Randomizer::*get_3)(int,double,double) =
&Randomizer::get ;
class_<Randomizer>( "Randomizer" )
.default_constructor()
.method( "get" , get_1 )
.method( "get" , get_2 )
.method( "get" , get_3 )
;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20140701/0aeecbb8/attachment.html>
More information about the Rcpp-devel
mailing list