[Rcpp-devel] overloaded methods

Chaomei Lo chaomeilo at gmail.com
Wed Aug 27 19:17:58 CEST 2014


Sorry to bug you all, I accidently sent a wrong message few minutes ago.

I have posted this problem few days ago, can anybody helps me with this
compilation error ? I do not have idea why there is no matching function...
It is from Romain's example -
http://lists.r-forge.r-project.org/pipermail/rcpp-devel/2010-November/001326.html.
I have attached the output of the compiling errors.

////////////////////////////////////////////////////////
class Randomizer {
public:

     Randomizer(){}

NumericVector get( int n ){
RNGScope scope ;
return runif( n, 0.0, 1.0 );
}

List get( IntegerVector n ){
RNGScope scope ;
int size = n.size() ;
List res( size) ;
for( int i=0; i<size; i++){
    res[i] = runif(n[i] , 0.0, 1.0 ) ;
}
return res ;
}

} ;

bool get_int_valid(SEXP* args, int nargs){
     if( nargs != 1 ) return false ;
     if( TYPEOF(args[0]) != INTSXP ) return false ;
     return ( LENGTH(args[0]) == 1 ) ;
}

RCPP_MODULE(mod){

class_<Randomizer>( "Randomizer" )

    .default_constructor()

.method( "get" , ( NumericVector (Randomizer::*)(int) )(
&Randomizer::get) , &get_int_valid )
.method( "get" , ( List (Randomizer::*)(IntegerVector) )(
&Randomizer::get) )
;


}

Thanks a bunch !
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20140827/d0402b07/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: overloaded.docx
Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document
Size: 14218 bytes
Desc: not available
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20140827/d0402b07/attachment.docx>


More information about the Rcpp-devel mailing list