CLHEP VERSION Reference Documentation
CLHEP Home Page CLHEP Documentation CLHEP Bug Reports |
00001 // ====================================================================== 00002 // 00003 // Test basic functionality of is_same type trait 00004 // 00005 // Author: W. E. Brown, 2010-03-24, adapted from the boost library's 00006 // type_traits and related functionality whose internal attributions bear 00007 // the following various notices: 00008 // 00009 // (C) Copyright John Maddock 2000. 00010 // Distributed under the Boost Software License, Version 1.0. 00011 // See http://www.boost.org/LICENSE_1_0.txt 00012 // 00013 // ====================================================================== 00014 00015 00016 #include "CLHEP/Utility/type_traits.h" 00017 00018 #include <cassert> 00019 00020 00021 using namespace CLHEP; 00022 using CLHEP::is_same; 00023 00024 00025 typedef int my_int; 00026 00027 00028 #define claim_same(From,To) (is_same<From,To>::value) 00029 #define has_same_type(From,To) assert(claim_same(From,To)) 00030 #define has_different_type(From,To) assert(!claim_same(From,To)) 00031 00032 00033 int main() 00034 { 00035 has_same_type(int, int); 00036 has_same_type(int, my_int); 00037 00038 has_different_type(int , void); 00039 has_different_type(int , const int); 00040 has_different_type(int , int&); 00041 has_different_type(const int, int&); 00042 has_different_type(int , const int&); 00043 has_different_type(int* , const int*); 00044 has_different_type(int* , int*const); 00045 has_different_type(int , int[2]); 00046 has_different_type(int* , int[2]); 00047 has_different_type(int[4] , int[2]); 00048 00049 return 0; 00050 }