Rcpp Version 1.0.7
is_na.h
Go to the documentation of this file.
1 // -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*-
2 //
3 // is_na.h: Rcpp R/C++ interface class library -- vector operators
4 //
5 // Copyright (C) 2010 - 2018 Dirk Eddelbuettel and Romain Francois
6 // Copyright (C) 2018 Dirk Eddelbuettel and Kirill Mueller
7 //
8 // This file is part of Rcpp.
9 //
10 // Rcpp is free software: you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 2 of the License, or
13 // (at your option) any later version.
14 //
15 // Rcpp is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with Rcpp. If not, see <http://www.gnu.org/licenses/>.
22 
23 #ifndef Rcpp__traits_is_na_h
24 #define Rcpp__traits_is_na_h
25 
26 namespace Rcpp{
27 
28  namespace traits{
29 
30  // default to always false, applies to VECSXP, EXPRSXP and RAWSXP
31  template <int RTYPE>
33  return false;
34  }
35 
36  template <>
37  inline bool is_na<INTSXP>(int x) {
38  return x == NA_INTEGER;
39  }
40 
41  template <>
42  inline bool is_na<REALSXP>(double x) {
43  return R_isnancpp(x);
44  }
45 
46  template <>
47  inline bool is_na<CPLXSXP>(Rcomplex x) {
48  return R_isnancpp(x.r) || R_isnancpp(x.i);
49  }
50 
51  template <>
52  inline bool is_na<STRSXP>(SEXP x) {
53  return x == NA_STRING;
54  }
55 
56  template <>
57  inline bool is_na<LGLSXP>(int x) {
58  return x == NA_LOGICAL;
59  }
60 
61  }
62 }
63 
64 #endif
Rcpp::traits::is_na< STRSXP >
bool is_na< STRSXP >(SEXP x)
Definition: is_na.h:52
Rcpp::traits::is_na< INTSXP >
bool is_na< INTSXP >(int x)
Definition: is_na.h:37
Rcpp::traits::is_na< REALSXP >
bool is_na< REALSXP >(double x)
Definition: is_na.h:42
Rcpp::traits::is_na< LGLSXP >
bool is_na< LGLSXP >(int x)
Definition: is_na.h:57
Rcpp
Rcpp API.
Definition: algo.h:28
Rcpp::traits::is_na
bool is_na(typename storage_type< RTYPE >::type)
Definition: is_na.h:32
Rcpp::traits::storage_type::type
SEXP type
Definition: storage_type.h:36
Rcpp::traits::is_na< CPLXSXP >
bool is_na< CPLXSXP >(Rcomplex x)
Definition: is_na.h:47