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 )
                ;


}
_______________________________________________
Rcpp-devel mailing list
Rcpp-devel@lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Reply via email to