CLHEP VERSION Reference Documentation
   
CLHEP Home Page     CLHEP Documentation     CLHEP Bug Reports

testIsSame.cc
Go to the documentation of this file.
1 // ======================================================================
2 //
3 // Test basic functionality of is_same type trait
4 //
5 // Author: W. E. Brown, 2010-03-24, adapted from the boost library's
6 // type_traits and related functionality whose internal attributions bear
7 // the following various notices:
8 //
9 // (C) Copyright John Maddock 2000.
10 // Distributed under the Boost Software License, Version 1.0.
11 // See http://www.boost.org/LICENSE_1_0.txt
12 //
13 // ======================================================================
14 
15 
16 #include "CLHEP/Utility/type_traits.h"
17 
18 #include <cassert>
19 
20 
21 using namespace CLHEP;
22 using CLHEP::is_same;
23 
24 
25 typedef int my_int;
26 
27 
28 #define claim_same(From,To) (is_same<From,To>::value)
29 #define has_same_type(From,To) assert(claim_same(From,To))
30 #define has_different_type(From,To) assert(!claim_same(From,To))
31 
32 
33 int main()
34 {
35  has_same_type(int, int);
36  has_same_type(int, my_int);
37 
38  has_different_type(int , void);
39  has_different_type(int , const int);
40  has_different_type(int , int&);
41  has_different_type(const int, int&);
42  has_different_type(int , const int&);
43  has_different_type(int* , const int*);
44  has_different_type(int* , int*const);
45  has_different_type(int , int[2]);
46  has_different_type(int* , int[2]);
47  has_different_type(int[4] , int[2]);
48 
49  return 0;
50 }
#define has_different_type(From, To)
Definition: testIsSame.cc:30
#define has_same_type(From, To)
Definition: testIsSame.cc:29
int main()
Definition: testIsSame.cc:33
int my_int
Definition: testIsSame.cc:25