Rcpp Version 1.0.9
is.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.h: Rcpp R/C++ interface class library -- test if an R Object can be seen
4 // as one type
5 //
6 // Copyright (C) 2013 Dirk Eddelbuettel and Romain Francois
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__is__h
24 #define Rcpp__is__h
25 
26 namespace Rcpp{
27 
28  namespace internal{
29 
30  // simple implementation, for most default types
31  template <typename T> bool is__simple( SEXP x) ;
32 
33  // implementation for module objects
34  template <typename T> bool is__module__object( SEXP x) ;
35 
36  // not a module object
37  template <typename T>
38  inline bool is__dispatch( SEXP x, Rcpp::traits::false_type ){
39  return is__simple<T>( x ) ;
40  }
41 
42  template <typename T>
43  inline bool is__dispatch( SEXP x, Rcpp::traits::true_type ){
44  return is__module__object<T>( x ) ;
45  }
46  }
47 
53  template <typename T> bool is( SEXP x ){
54  return internal::is__dispatch<T>( x, typename traits::is_module_object<T>::type() ) ;
55  }
56 
57 } // Rcpp
58 
59 #endif
bool is__dispatch(SEXP x, Rcpp::traits::false_type)
Definition: is.h:38
bool is__simple(SEXP x)
bool is__module__object(SEXP x)
Definition: is.h:160
Rcpp API.
Definition: algo.h:28
bool is(SEXP x)
Definition: is.h:53