Viskores  1.0
TypeTraits.h
Go to the documentation of this file.
1 //============================================================================
2 // The contents of this file are covered by the Viskores license. See
3 // LICENSE.txt for details.
4 //
5 // By contributing to this file, all contributors agree to the Developer
6 // Certificate of Origin Version 1.1 (DCO 1.1) as stated in DCO.txt.
7 //============================================================================
8 
9 //============================================================================
10 // Copyright (c) Kitware, Inc.
11 // All rights reserved.
12 // See LICENSE.txt for details.
13 //
14 // This software is distributed WITHOUT ANY WARRANTY; without even
15 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
16 // PURPOSE. See the above copyright notice for more information.
17 //============================================================================
18 #ifndef viskores_TypeTraits_h
19 #define viskores_TypeTraits_h
20 
21 #include <viskores/Types.h>
22 
23 namespace viskores
24 {
25 
29 {
30 };
31 
37 {
38 };
39 
45 {
46 };
47 
53 {
54 };
55 
60 {
61 };
62 
68 template <typename T>
70 {
71 public:
76 
82 
85  VISKORES_EXEC_CONT static T ZeroInitialization() { return T(); }
86 };
87 
88 // Const types should have the same traits as their non-const counterparts.
89 //
90 template <typename T>
91 struct TypeTraits<const T> : TypeTraits<T>
92 {
93 };
94 
95 #define VISKORES_BASIC_REAL_TYPE(T) \
96  template <> \
97  struct TypeTraits<T> \
98  { \
99  using NumericTag = TypeTraitsRealTag; \
100  using DimensionalityTag = TypeTraitsScalarTag; \
101  VISKORES_EXEC_CONT static T ZeroInitialization() \
102  { \
103  return T(); \
104  } \
105  };
106 
107 #define VISKORES_BASIC_INTEGER_TYPE(T) \
108  template <> \
109  struct TypeTraits<T> \
110  { \
111  using NumericTag = TypeTraitsIntegerTag; \
112  using DimensionalityTag = TypeTraitsScalarTag; \
113  VISKORES_EXEC_CONT static T ZeroInitialization() \
114  { \
115  using ReturnType = T; \
116  return ReturnType(); \
117  } \
118  };
119 
122 
125 
137 VISKORES_BASIC_INTEGER_TYPE(unsigned long long)
138 
139 #undef VISKORES_BASIC_REAL_TYPE
140 #undef VISKORES_BASIC_INTEGER_TYPE
141 
144 template <typename T, viskores::IdComponent Size>
145 struct TypeTraits<viskores::Vec<T, Size>>
146 {
149 
152  {
154  }
155 };
156 
159 template <typename T>
161 {
164 
167 };
168 
171 template <typename T>
173 {
176 
179 };
180 
183 template <typename T, typename U>
184 struct TypeTraits<viskores::Pair<T, U>>
185 {
188 
191  {
194  }
195 };
196 
197 } // namespace viskores
198 
199 #endif //viskores_TypeTraits_h
viskores::TypeTraits< viskores::VecCConst< T > >::ZeroInitialization
static viskores::VecCConst< T > ZeroInitialization()
Definition: TypeTraits.h:166
viskores::TypeTraits< viskores::VecC< T > >::ZeroInitialization
static viskores::VecC< T > ZeroInitialization()
Definition: TypeTraits.h:178
viskores::TypeTraits< viskores::VecCConst< T > >::NumericTag
typename viskores::TypeTraits< T >::NumericTag NumericTag
Definition: TypeTraits.h:162
viskores::VecCConst
A const version of VecC.
Definition: Types.h:371
Types.h
viskores::TypeTraits< viskores::Vec< T, Size > >::NumericTag
typename viskores::TypeTraits< T >::NumericTag NumericTag
Definition: TypeTraits.h:147
viskores::TypeTraits::ZeroInitialization
static T ZeroInitialization()
A static function that returns 0 (or the closest equivalent to it) for the given type.
Definition: TypeTraits.h:85
viskores::VecC
A Vec-like representation for short arrays.
Definition: Types.h:368
VISKORES_EXEC_CONT
#define VISKORES_EXEC_CONT
Definition: ExportMacros.h:60
viskores::TypeTraitsScalarTag
Tag used to identify 0 dimensional types (scalars).
Definition: TypeTraits.h:52
viskores::TypeTraits
The TypeTraits class provides helpful compile-time information about the basic types used in Viskores...
Definition: TypeTraits.h:69
viskores
Groups connected points that have the same field value.
Definition: Atomic.h:27
viskores::TypeTraitsUnknownTag
Tag used to identify types that aren't Real, Integer, Scalar or Vector.
Definition: TypeTraits.h:28
viskores::TypeTraitsRealTag
Tag used to identify types that store real (floating-point) numbers.
Definition: TypeTraits.h:36
VISKORES_BASIC_REAL_TYPE
#define VISKORES_BASIC_REAL_TYPE(T)
Definition: TypeTraits.h:95
VISKORES_BASIC_INTEGER_TYPE
#define VISKORES_BASIC_INTEGER_TYPE(T)
Definition: TypeTraits.h:107
viskores::Pair
A viskores::Pair is essentially the same as an STL pair object except that the methods (constructors ...
Definition: Pair.h:37
viskores::TypeTraits< viskores::Vec< T, Size > >::ZeroInitialization
static viskores::Vec< T, Size > ZeroInitialization()
Definition: TypeTraits.h:151
viskores::TypeTraits< viskores::VecC< T > >::NumericTag
typename viskores::TypeTraits< T >::NumericTag NumericTag
Definition: TypeTraits.h:174
viskores::TypeTraitsVectorTag
Tag used to identify 1 dimensional types (vectors).
Definition: TypeTraits.h:59
viskores::Vec
A short fixed-length array.
Definition: Types.h:365
viskores::TypeTraitsIntegerTag
Tag used to identify types that store integer numbers.
Definition: TypeTraits.h:44
viskores::TypeTraits< viskores::Pair< T, U > >::ZeroInitialization
static viskores::Pair< T, U > ZeroInitialization()
Definition: TypeTraits.h:190