Flow Visualisation
_detail.hpp
Go to the documentation of this file.
1 
29 #ifndef glm_core_detail
30 #define glm_core_detail
31 
32 #include "setup.hpp"
33 #include <cassert>
34 #if(defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L))
35 #include <cstdint>
36 #endif
37 
38 namespace glm{
39 namespace detail
40 {
41  class half;
42 
43 #if(defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) // C99 detected, 64 bit types available
44  typedef int64_t sint64;
45  typedef uint64_t uint64;
46 #elif(GLM_COMPILER & GLM_COMPILER_VC)
47  typedef signed __int64 sint64;
48  typedef unsigned __int64 uint64;
49 #elif(GLM_COMPILER & (GLM_COMPILER_GCC | GLM_COMPILER_LLVM_GCC | GLM_COMPILER_CLANG))
50  __extension__ typedef signed long long sint64;
51  __extension__ typedef unsigned long long uint64;
52 #elif(GLM_COMPILER & GLM_COMPILER_BC)
53  typedef Int64 sint64;
54  typedef Uint64 uint64;
55 #else//unknown compiler
56  typedef signed long long sint64;
57  typedef unsigned long long uint64;
58 #endif//GLM_COMPILER
59 
60  template<bool C>
61  struct If
62  {
63  template<typename F, typename T>
64  static GLM_FUNC_QUALIFIER T apply(F functor, const T& val)
65  {
66  return functor(val);
67  }
68  };
69 
70  template<>
71  struct If<false>
72  {
73  template<typename F, typename T>
74  static GLM_FUNC_QUALIFIER T apply(F, const T& val)
75  {
76  return val;
77  }
78  };
79 
80  //template <typename T>
81  //struct traits
82  //{
83  // static const bool is_signed = false;
84  // static const bool is_float = false;
85  // static const bool is_vector = false;
86  // static const bool is_matrix = false;
87  // static const bool is_genType = false;
88  // static const bool is_genIType = false;
89  // static const bool is_genUType = false;
90  //};
91 
92  //template <>
93  //struct traits<half>
94  //{
95  // static const bool is_float = true;
96  // static const bool is_genType = true;
97  //};
98 
99  //template <>
100  //struct traits<float>
101  //{
102  // static const bool is_float = true;
103  // static const bool is_genType = true;
104  //};
105 
106  //template <>
107  //struct traits<double>
108  //{
109  // static const bool is_float = true;
110  // static const bool is_genType = true;
111  //};
112 
113  //template <typename genType>
114  //struct desc
115  //{
116  // typedef genType type;
117  // typedef genType * pointer;
118  // typedef genType const* const_pointer;
119  // typedef genType const *const const_pointer_const;
120  // typedef genType *const pointer_const;
121  // typedef genType & reference;
122  // typedef genType const& const_reference;
123  // typedef genType const& param_type;
124 
125  // typedef typename genType::value_type value_type;
126  // typedef typename genType::size_type size_type;
127  // static const typename size_type value_size;
128  //};
129 
130  //template <typename genType>
131  //const typename desc<genType>::size_type desc<genType>::value_size = genType::value_size();
132 
133  union uif32
134  {
136  i(0)
137  {}
138 
140  f(f)
141  {}
142 
143  GLM_FUNC_QUALIFIER uif32(unsigned int i) :
144  i(i)
145  {}
146 
147  float f;
148  unsigned int i;
149  };
150 
151  union uif64
152  {
154  i(0)
155  {}
156 
158  f(f)
159  {}
160 
162  i(i)
163  {}
164 
165  double f;
166  uint64 i;
167  };
168 
169  typedef uif32 uif;
170 
172  // int
173 
174  template <typename T>
175  struct is_int
176  {
178  {
179  _YES = 0,
180  _NO = 1
181  };
182  };
183 
184 #define GLM_DETAIL_IS_INT(T) \
185  template <> \
186  struct is_int<T> \
187  { \
188  enum is_int_enum \
189  { \
190  _YES = 1, \
191  _NO = 0 \
192  }; \
193  }
194 
196  // uint
197 
198  template <typename T>
199  struct is_uint
200  {
202  {
203  _YES = 0,
204  _NO = 1
205  };
206  };
207 
208 #define GLM_DETAIL_IS_UINT(T) \
209  template <> \
210  struct is_uint<T> \
211  { \
212  enum is_uint_enum \
213  { \
214  _YES = 1, \
215  _NO = 0 \
216  }; \
217  }
218 
219  //GLM_DETAIL_IS_UINT(unsigned long long)
220 
222  // float
223 
224  template <typename T>
225  struct is_float
226  {
228  {
229  _YES = 0,
230  _NO = 1
231  };
232  };
233 
234 #define GLM_DETAIL_IS_FLOAT(T) \
235  template <> \
236  struct is_float<T> \
237  { \
238  enum is_float_enum \
239  { \
240  _YES = 1, \
241  _NO = 0 \
242  }; \
243  }
244 
246  GLM_DETAIL_IS_FLOAT(float);
247  GLM_DETAIL_IS_FLOAT(double);
248  GLM_DETAIL_IS_FLOAT(long double);
249 
251  // bool
252 
253  template <typename T>
254  struct is_bool
255  {
257  {
258  _YES = 0,
259  _NO = 1
260  };
261  };
262 
263  template <>
264  struct is_bool<bool>
265  {
267  {
268  _YES = 1,
269  _NO = 0
270  };
271  };
272 
274  // vector
275 
276  template <typename T>
277  struct is_vector
278  {
280  {
281  _YES = 0,
282  _NO = 1
283  };
284  };
285 
286 # define GLM_DETAIL_IS_VECTOR(TYPE) \
287  template <typename T> \
288  struct is_vector<TYPE<T> > \
289  { \
290  enum is_vector_enum \
291  { \
292  _YES = 1, \
293  _NO = 0 \
294  }; \
295  }
296 
298  // matrix
299 
300  template <typename T>
301  struct is_matrix
302  {
304  {
305  _YES = 0,
306  _NO = 1
307  };
308  };
309 
310 #define GLM_DETAIL_IS_MATRIX(T) \
311  template <> \
312  struct is_matrix \
313  { \
314  enum is_matrix_enum \
315  { \
316  _YES = 1, \
317  _NO = 0 \
318  }; \
319  }
320 
322  // type
323 
324  template <typename T>
325  struct type
326  {
328  {
333  };
334  };
335 
337  // type
338 
339  typedef signed char int8;
340  typedef signed short int16;
341  typedef signed int int32;
343 
344  typedef unsigned char uint8;
345  typedef unsigned short uint16;
346  typedef unsigned int uint32;
347  typedef detail::uint64 uint64;
348 
350  typedef float float32;
351  typedef double float64;
352 
354  // float_or_int_trait
355 
357  {
358  enum
359  {
363  };
364  };
365 
366  template <typename T>
368  {
370  };
371 
372  template <>
373  struct float_or_int_trait<int8>
374  {
376  };
377 
378  template <>
379  struct float_or_int_trait<int16>
380  {
382  };
383 
384  template <>
385  struct float_or_int_trait<int32>
386  {
388  };
389 
390  template <>
391  struct float_or_int_trait<int64>
392  {
394  };
395 
396  template <>
397  struct float_or_int_trait<uint8>
398  {
400  };
401 
402  template <>
403  struct float_or_int_trait<uint16>
404  {
406  };
407 
408  template <>
409  struct float_or_int_trait<uint32>
410  {
412  };
413 
414  template <>
415  struct float_or_int_trait<uint64>
416  {
418  };
419 
420  template <>
421  struct float_or_int_trait<float16>
422  {
424  };
425 
426  template <>
427  struct float_or_int_trait<float32>
428  {
430  };
431 
432  template <>
433  struct float_or_int_trait<float64>
434  {
436  };
437 
438 }//namespace detail
439 }//namespace glm
440 
441 #if((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2005))
442 # define GLM_DEPRECATED __declspec(deprecated)
443 # define GLM_ALIGN(x) __declspec(align(x))
444 # define GLM_ALIGNED_STRUCT(x) __declspec(align(x)) struct
445 # define GLM_RESTRICT __declspec(restrict)
446 # define GLM_RESTRICT_VAR __restrict
447 # define GLM_CONSTEXPR
448 #elif(GLM_COMPILER & GLM_COMPILER_INTEL)
449 # define GLM_DEPRECATED
450 # define GLM_ALIGN(x) __declspec(align(x))
451 # define GLM_ALIGNED_STRUCT(x) __declspec(align(x)) struct
452 # define GLM_RESTRICT
453 # define GLM_RESTRICT_VAR __restrict
454 # define GLM_CONSTEXPR
455 #elif(((GLM_COMPILER & (GLM_COMPILER_GCC | GLM_COMPILER_LLVM_GCC)) && (GLM_COMPILER >= GLM_COMPILER_GCC31)) || (GLM_COMPILER & GLM_COMPILER_CLANG))
456 # define GLM_DEPRECATED __attribute__((__deprecated__))
457 # define GLM_ALIGN(x) __attribute__((aligned(x)))
458 # define GLM_ALIGNED_STRUCT(x) struct __attribute__((aligned(x)))
459 # if(GLM_COMPILER >= GLM_COMPILER_GCC33)
460 # define GLM_RESTRICT __restrict__
461 # define GLM_RESTRICT_VAR __restrict__
462 # else
463 # define GLM_RESTRICT
464 # define GLM_RESTRICT_VAR
465 # endif
466 # define GLM_RESTRICT __restrict__
467 # define GLM_RESTRICT_VAR __restrict__
468 # if((GLM_COMPILER >= GLM_COMPILER_GCC47) && ((GLM_LANG & GLM_LANG_CXX0X) == GLM_LANG_CXX0X))
469 # define GLM_CONSTEXPR constexpr
470 # else
471 # define GLM_CONSTEXPR
472 # endif
473 #else
474 # define GLM_DEPRECATED
475 # define GLM_ALIGN
476 # define GLM_ALIGNED_STRUCT(x)
477 # define GLM_RESTRICT
478 # define GLM_RESTRICT_VAR
479 # define GLM_CONSTEXPR
480 #endif//GLM_COMPILER
481 
482 #endif//glm_core_detail
Definition: _detail.hpp:369
Definition: _detail.hpp:254
is_bool_enum
Definition: _detail.hpp:256
unsigned long long uint64
Definition: _detail.hpp:57
Definition: _detail.hpp:229
signed long long sint64
Definition: _detail.hpp:41
detail::int64 int64_t
Definition: type_precision.hpp:94
Definition: _detail.hpp:305
uif32 uif
Definition: _detail.hpp:169
Definition: _detail.hpp:230
Definition: _detail.hpp:301
GLM_FUNC_QUALIFIER uif64(uint64 i)
Definition: _detail.hpp:161
Definition: _detail.hpp:38
signed short int16
Definition: _detail.hpp:340
double float64
Definition: _detail.hpp:351
Definition: _detail.hpp:306
unsigned int i
Definition: _detail.hpp:148
detail::half half
Definition: half_float.hpp:357
uint64 i
Definition: _detail.hpp:166
Definition: _detail.hpp:225
unsigned int uint32
Definition: _detail.hpp:346
Definition: _swizzle.hpp:43
Definition: _detail.hpp:258
signed int int32
Definition: _detail.hpp:341
Definition: _detail.hpp:367
Definition: _detail.hpp:362
GLM_FUNC_QUALIFIER uif32()
Definition: _detail.hpp:135
GLM_FUNC_QUALIFIER uif32(float f)
Definition: _detail.hpp:139
is_float_enum
Definition: _detail.hpp:227
unsigned short uint16
Definition: _detail.hpp:345
double f
Definition: _detail.hpp:165
unsigned char uint8
Definition: _detail.hpp:344
static GLM_FUNC_QUALIFIER T apply(F functor, const T &val)
Definition: _detail.hpp:64
is_vector_enum
Definition: _detail.hpp:279
Definition: _detail.hpp:180
is_uint_enum
Definition: _detail.hpp:201
detail::uint64 uint64_t
Definition: type_precision.hpp:216
type_enum
Definition: _detail.hpp:327
GLM_FUNC_QUALIFIER uif64()
Definition: _detail.hpp:153
GLM_FUNC_QUALIFIER uif64(double f)
Definition: _detail.hpp:157
Definition: _detail.hpp:277
Definition: _detail.hpp:282
Definition: _detail.hpp:199
Definition: _detail.hpp:259
GLM_FUNC_QUALIFIER uif32(unsigned int i)
Definition: _detail.hpp:143
Definition: type_half.hpp:42
detail::sint64 int64
Definition: _detail.hpp:342
Definition: _detail.hpp:281
float float32
Definition: _detail.hpp:350
Definition: _detail.hpp:151
Definition: _detail.hpp:203
is_matrix_enum
Definition: _detail.hpp:303
Definition: _detail.hpp:356
Definition: _detail.hpp:175
static GLM_FUNC_QUALIFIER T apply(F, const T &val)
Definition: _detail.hpp:74
Definition: _detail.hpp:325
detail::half float16
Definition: _detail.hpp:349
Definition: _detail.hpp:133
float f
Definition: _detail.hpp:147
is_bool_enum
Definition: _detail.hpp:266
signed char int8
Definition: _detail.hpp:339
Definition: _detail.hpp:179
Definition: _detail.hpp:61
Definition: _detail.hpp:204
GLM_DETAIL_IS_FLOAT(detail::half)
is_int_enum
Definition: _detail.hpp:177
#define GLM_FUNC_QUALIFIER
Definition: setup.hpp:679