HasSize.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_UTIL_TYPETRAITS_HASSIZE_H_
36 #define _BLAZE_UTIL_TYPETRAITS_HASSIZE_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <blaze/util/FalseType.h>
44 #include <blaze/util/SelectType.h>
45 #include <blaze/util/TrueType.h>
46 #include <blaze/util/Types.h>
47 
48 
49 namespace blaze {
50 
51 //=================================================================================================
52 //
53 // CLASS HASSIZE
54 //
55 //=================================================================================================
56 
57 //*************************************************************************************************
75 template< typename T, size_t Size >
76 struct HasSize : public SelectType< sizeof( T ) == Size, TrueType, FalseType >::Type
77 {
78  public:
79  //**********************************************************************************************
81  enum { value = ( sizeof( T ) == Size ) };
82  typedef typename SelectType<value,TrueType,FalseType>::Type Type;
84  //**********************************************************************************************
85 };
86 //*************************************************************************************************
87 
88 
89 //*************************************************************************************************
100 template< size_t Size >
101 struct HasSize<void,Size> : public SelectType< 0 == Size, TrueType, FalseType >::Type
102 {
103  public:
104  //**********************************************************************************************
105  enum { value = ( 0 == Size ) };
106  typedef typename SelectType<value,TrueType,FalseType>::Type Type;
107  //**********************************************************************************************
108 };
110 //*************************************************************************************************
111 
112 
113 //*************************************************************************************************
124 template< size_t Size >
125 struct HasSize<const void,Size> : public SelectType< 0 == Size, TrueType, FalseType >::Type
126 {
127  public:
128  //**********************************************************************************************
129  enum { value = ( 0 == Size ) };
130  typedef typename SelectType<value,TrueType,FalseType>::Type Type;
131  //**********************************************************************************************
132 };
134 //*************************************************************************************************
135 
136 
137 //*************************************************************************************************
148 template< size_t Size >
149 struct HasSize<volatile void,Size> : public SelectType< 0 == Size, TrueType, FalseType >::Type
150 {
151  public:
152  //**********************************************************************************************
153  enum { value = ( 0 == Size ) };
154  typedef typename SelectType<value,TrueType,FalseType>::Type Type;
155  //**********************************************************************************************
156 };
158 //*************************************************************************************************
159 
160 
161 //*************************************************************************************************
172 template< size_t Size >
173 struct HasSize<const volatile void,Size> : public SelectType< 0 == Size, TrueType, FalseType >::Type
174 {
175  public:
176  //**********************************************************************************************
177  enum { value = ( 0 == Size ) };
178  typedef typename SelectType<value,TrueType,FalseType>::Type Type;
179  //**********************************************************************************************
180 };
182 //*************************************************************************************************
183 
184 
185 
186 
187 //=================================================================================================
188 //
189 // CLASS HAS1BYTE
190 //
191 //=================================================================================================
192 
193 //*************************************************************************************************
212 template< typename T >
213 struct Has1Byte : public HasSize<T,1UL>
214 {};
215 //*************************************************************************************************
216 
217 
218 
219 
220 //=================================================================================================
221 //
222 // CLASS HAS2BYTES
223 //
224 //=================================================================================================
225 
226 //*************************************************************************************************
245 template< typename T >
246 struct Has2Bytes : public HasSize<T,2UL>
247 {};
248 //*************************************************************************************************
249 
250 
251 
252 
253 //=================================================================================================
254 //
255 // CLASS HAS4BYTES
256 //
257 //=================================================================================================
258 
259 //*************************************************************************************************
278 template< typename T >
279 struct Has4Bytes : public HasSize<T,4UL>
280 {};
281 //*************************************************************************************************
282 
283 
284 
285 
286 //=================================================================================================
287 //
288 // CLASS HAS8BYTES
289 //
290 //=================================================================================================
291 
292 //*************************************************************************************************
311 template< typename T >
312 struct Has8Bytes : public HasSize<T,8UL>
313 {};
314 //*************************************************************************************************
315 
316 } // namespace blaze
317 
318 #endif
Header file for basic type definitions.
Header file for the FalseType type/value trait base class.
Compile time size check.This type trait offers the possibility to test whether a given type has a siz...
Definition: HasSize.h:213
Compile time size check.This class offers the possibility to test the size of a type at compile time...
Definition: HasSize.h:76
Compile time size check.This type trait offers the possibility to test whether a given type has a siz...
Definition: HasSize.h:246
Compile time type selection.The SelectType class template selects one of the two given types T1 and T...
Definition: SelectType.h:59
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
Header file for the SelectType class template.
Compile time size check.This type trait offers the possibility to test whether a given type has a siz...
Definition: HasSize.h:279
Compile time size check.This type trait offers the possibility to test whether a given type has a siz...
Definition: HasSize.h:312
Compile time evaluation of the size of a vector.The Size type trait evaluates the size of the given v...
Definition: Size.h:75
Header file for the TrueType type/value trait base class.