[Rcpp-devel] Traits for NA?

Romain Francois romain at r-enthusiasts.com
Tue Apr 9 13:17:44 CEST 2013


Le 09/04/13 09:51, Kirill Müller a écrit :
> Hi
>
> What is the best way to determine the NA value for a specific type given
> the type identifier (as returned by TYPEOF()), preferably as a
> compile-time constant?
>
> I'm looking for something along the following lines:
>
> static_assert(NA_traits<REALSXP>::value == NA_REAL);
> static_assert(NA_traits<LGLSXP>::value == NA_LOGICAL);
>
> Thanks.
>
>
> Cheers
>
> Kirill

You have these to get the NA and test against it

Rcpp::traits::is_na<RTYPE>(.)
Rcpp::traits::get_na<RTYPE>()

Romain

-- 
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30

R Graph Gallery: http://gallery.r-enthusiasts.com

blog:            http://blog.r-enthusiasts.com
|- http://bit.ly/ZTFLDo : Simpler R help tooltips
`- http://bit.ly/YFsziW : R Help tooltips



More information about the Rcpp-devel mailing list