Skip to content
Prev 2575 / 10988 Next

[Rcpp-devel] templated NA

Le 23/06/11 20:48, Andrew Redd a ?crit :
You might get what you want using a combination of the traits::get_na 
and traits::r_sexptype_traits templates.

Something like :

require( Rcpp )
require( inline )

inc <- '
     typedef double mtime ;

     template <typename T>
     inline T NA(){
         return traits::get_na< traits::r_sexptype_traits<T>::rtype >() ;
     }


'
fx <- cxxfunction( , '
     mtime na = NA<mtime>() ;
     return wrap( na ) ;
', inc = inc, plugin = "Rcpp" )
fx()