phdMesh  Version of the Day
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Groups
Basics.hpp
1 /*------------------------------------------------------------------------*/
2 /* phdMesh : Parallel Heterogneous Dynamic unstructured Mesh */
3 /* Copyright (2007) Sandia Corporation */
4 /* */
5 /* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */
6 /* license for use of this work by or on behalf of the U.S. Government. */
7 /* */
8 /* This library is free software; you can redistribute it and/or modify */
9 /* it under the terms of the GNU Lesser General Public License as */
10 /* published by the Free Software Foundation; either version 2.1 of the */
11 /* License, or (at your option) any later version. */
12 /* */
13 /* This library is distributed in the hope that it will be useful, */
14 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
15 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */
16 /* Lesser General Public License for more details. */
17 /* */
18 /* You should have received a copy of the GNU Lesser General Public */
19 /* License along with this library; if not, write to the Free Software */
20 /* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 */
21 /* USA */
22 /*------------------------------------------------------------------------*/
23 
24 #ifndef util_Basics_hpp
25 #define util_Basics_hpp
26 
27 namespace phdmesh {
28 
35 //----------------------------------------------------------------------
43 template< bool expression > struct StaticAssert {};
44 
45 template<> struct StaticAssert<true> {
46  enum { OK = true };
47  static bool ok() { return true ; }
48 };
49 
50 //----------------------------------------------------------------------
51 // Selection of an integer type based upon sign and size
52 
53 #ifndef DOXYGEN_COMPILE
54 
55 template<
56  unsigned size_char = sizeof( unsigned char ) ,
57  unsigned size_short = sizeof( unsigned short ) ,
58  unsigned size_int = sizeof( unsigned int ) ,
59  unsigned size_long = sizeof( unsigned long ) ,
60  unsigned size_ptr = sizeof( void * ) >
61 struct IntegerFundamentalTypes ;
62 
63 template<>
64 struct IntegerFundamentalTypes<1,2,4,8,4> {
65  typedef signed char int8_type ;
66  typedef unsigned char uint8_type ;
67  typedef signed short int16_type ;
68  typedef unsigned short uint16_type ;
69  typedef signed int int32_type ;
70  typedef unsigned int uint32_type ;
71  typedef signed long int64_type ;
72  typedef unsigned long uint64_type ;
73  typedef signed int intptr_type ;
74  typedef unsigned int uintptr_type ;
75 };
76 
77 template<>
78 struct IntegerFundamentalTypes<1,2,4,8,8> {
79  typedef signed char int8_type ;
80  typedef unsigned char uint8_type ;
81  typedef signed short int16_type ;
82  typedef unsigned short uint16_type ;
83  typedef signed int int32_type ;
84  typedef unsigned int uint32_type ;
85  typedef signed long int64_type ;
86  typedef unsigned long uint64_type ;
87  typedef signed long intptr_type ;
88  typedef unsigned long uintptr_type ;
89 };
90 
91 template<>
92 struct IntegerFundamentalTypes<1,2,4,4,4> {
93  typedef signed char int8_type ;
94  typedef unsigned char uint8_type ;
95  typedef signed short int16_type ;
96  typedef unsigned short uint16_type ;
97  typedef signed int int32_type ;
98  typedef unsigned int uint32_type ;
99  typedef signed long long int64_type ;
100  typedef unsigned long long uint64_type ;
101  typedef signed long intptr_type ;
102  typedef unsigned long uintptr_type ;
103 };
104 
105 template<>
106 struct IntegerFundamentalTypes<1,2,4,4,8> {
107  typedef signed char int8_type ;
108  typedef unsigned char uint8_type ;
109  typedef signed short int16_type ;
110  typedef unsigned short uint16_type ;
111  typedef signed int int32_type ;
112  typedef unsigned int uint32_type ;
113  typedef signed long long int64_type ;
114  typedef unsigned long long uint64_type ;
115  typedef signed long long intptr_type ;
116  typedef unsigned long long uintptr_type ;
117 };
118 
119 #endif /* DOXYGEN_COMPILE */
120 
121 typedef IntegerFundamentalTypes<>::int8_type int8_type ;
122 typedef IntegerFundamentalTypes<>::uint8_type uint8_type ;
123 typedef IntegerFundamentalTypes<>::int16_type int16_type ;
124 typedef IntegerFundamentalTypes<>::uint16_type uint16_type ;
125 typedef IntegerFundamentalTypes<>::int32_type int32_type ;
126 typedef IntegerFundamentalTypes<>::uint32_type uint32_type ;
127 typedef IntegerFundamentalTypes<>::int64_type int64_type ;
128 typedef IntegerFundamentalTypes<>::uint64_type uint64_type ;
129 typedef IntegerFundamentalTypes<>::intptr_type intptr_type ;
130 typedef IntegerFundamentalTypes<>::uintptr_type uintptr_type ;
131 
134 } // namespace phdmesh
135 
136 #endif
137 
Compiler-enforced value of 'expression == true'.
Definition: Basics.hpp:43