Rcpp Version 0.9.10
expands_to_logical.h
Go to the documentation of this file.
00001 // -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
00002 /* :tabSize=4:indentSize=4:noTabs=false:folding=explicit:collapseFolds=1: */
00003 //
00004 // expands_to_logical.h: Rcpp R/C++ interface class library -- 
00005 //
00006 // Copyright (C) 2010 - 2011 Dirk Eddelbuettel and Romain Francois
00007 //
00008 // This file is part of Rcpp.
00009 //
00010 // Rcpp is free software: you can redistribute it and/or modify it
00011 // under the terms of the GNU General Public License as published by
00012 // the Free Software Foundation, either version 2 of the License, or
00013 // (at your option) any later version.
00014 //
00015 // Rcpp is distributed in the hope that it will be useful, but
00016 // WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 // GNU General Public License for more details.
00019 //
00020 // You should have received a copy of the GNU General Public License
00021 // along with Rcpp.  If not, see <http://www.gnu.org/licenses/>.
00022 
00023 #ifndef Rcpp__traits__expands_to_logical_h
00024 #define Rcpp__traits__expands_to_logical_h
00025 
00026 // helper trait to disambiguate things that want to be logical vectors
00027 // from containers of int
00028 
00029 namespace Rcpp{
00030 namespace traits{
00031 
00032         template <int RTYPE>
00033         struct expands_to_logical__impl{} ;
00034         
00035         template <>
00036         struct expands_to_logical__impl<LGLSXP> {
00037                 struct r_expands_to_logical{}; 
00038         } ;
00039 
00040         template<typename T>
00041         class _has_rtype_helper : __sfinae_types {
00042       template<typename U> struct _Wrap_type { };
00043 
00044       template<typename U>
00045         static __one __test(_Wrap_type<typename U::r_expands_to_logical>*);
00046 
00047       template<typename U>
00048         static __two __test(...);
00049 
00050     public:
00051       static const bool value = sizeof(__test<T>(0)) == 1;
00052     };
00053   
00054   template<typename T> struct expands_to_logical : 
00055         integral_constant<bool, _has_rtype_helper<T>::value >{ };
00056     
00057     
00058 } 
00059 }
00060 
00061 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Defines