VTK-m  2.0
TypeTraits.h
Go to the documentation of this file.
1 //============================================================================
2 // Copyright (c) Kitware, Inc.
3 // All rights reserved.
4 // See LICENSE.txt for details.
5 //
6 // This software is distributed WITHOUT ANY WARRANTY; without even
7 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
8 // PURPOSE. See the above copyright notice for more information.
9 //============================================================================
10 #ifndef vtk_m_TypeTraits_h
11 #define vtk_m_TypeTraits_h
12 
13 #include <vtkm/Types.h>
14 
15 namespace vtkm
16 {
17 
21 {
22 };
23 
29 {
30 };
31 
37 {
38 };
39 
45 {
46 };
47 
52 {
53 };
54 
60 template <typename T>
62 {
63 public:
68 
74 
75  VTKM_EXEC_CONT static T ZeroInitialization() { return T(); }
76 };
77 
78 // Const types should have the same traits as their non-const counterparts.
79 //
80 template <typename T>
81 struct TypeTraits<const T> : TypeTraits<T>
82 {
83 };
84 
85 #define VTKM_BASIC_REAL_TYPE(T) \
86  template <> \
87  struct TypeTraits<T> \
88  { \
89  using NumericTag = TypeTraitsRealTag; \
90  using DimensionalityTag = TypeTraitsScalarTag; \
91  VTKM_EXEC_CONT static T ZeroInitialization() { return T(); } \
92  };
93 
94 #define VTKM_BASIC_INTEGER_TYPE(T) \
95  template <> \
96  struct TypeTraits<T> \
97  { \
98  using NumericTag = TypeTraitsIntegerTag; \
99  using DimensionalityTag = TypeTraitsScalarTag; \
100  VTKM_EXEC_CONT static T ZeroInitialization() \
101  { \
102  using ReturnType = T; \
103  return ReturnType(); \
104  } \
105  };
106 
109 
111 VTKM_BASIC_REAL_TYPE(double)
112 
115 VTKM_BASIC_INTEGER_TYPE(signed char)
116 VTKM_BASIC_INTEGER_TYPE(unsigned char)
118 VTKM_BASIC_INTEGER_TYPE(unsigned short)
120 VTKM_BASIC_INTEGER_TYPE(unsigned int)
122 VTKM_BASIC_INTEGER_TYPE(unsigned long)
123 VTKM_BASIC_INTEGER_TYPE(long long)
124 VTKM_BASIC_INTEGER_TYPE(unsigned long long)
125 
126 #undef VTKM_BASIC_REAL_TYPE
127 #undef VTKM_BASIC_INTEGER_TYPE
128 
131 template <typename T, vtkm::IdComponent Size>
132 struct TypeTraits<vtkm::Vec<T, Size>>
133 {
136 
139  {
141  }
142 };
143 
146 template <typename T>
148 {
151 
154 };
155 
158 template <typename T>
159 struct TypeTraits<vtkm::VecC<T>>
160 {
163 
166 };
167 
170 template <typename T, typename U>
171 struct TypeTraits<vtkm::Pair<T, U>>
172 {
175 
178  {
181  }
182 };
183 
184 } // namespace vtkm
185 
186 #endif //vtk_m_TypeTraits_h
vtkm::TypeTraits< vtkm::VecCConst< T > >::ZeroInitialization
static VTKM_EXEC_CONT vtkm::VecCConst< T > ZeroInitialization()
Definition: TypeTraits.h:153
vtkm::TypeTraits< vtkm::Vec< T, Size > >::ZeroInitialization
static VTKM_EXEC_CONT vtkm::Vec< T, Size > ZeroInitialization()
Definition: TypeTraits.h:138
vtkm::TypeTraitsIntegerTag
Tag used to identify types that store integer numbers.
Definition: TypeTraits.h:36
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
vtkm::TypeTraits
The TypeTraits class provides helpful compile-time information about the basic types used in VTKm (an...
Definition: TypeTraits.h:61
Types.h
VTKM_EXEC_CONT
#define VTKM_EXEC_CONT
Definition: ExportMacros.h:52
vtkm::TypeTraits< vtkm::VecC< T > >::NumericTag
typename vtkm::TypeTraits< T >::NumericTag NumericTag
Definition: TypeTraits.h:161
VTKM_BASIC_INTEGER_TYPE
#define VTKM_BASIC_INTEGER_TYPE(T)
Definition: TypeTraits.h:94
VTKM_BASIC_REAL_TYPE
#define VTKM_BASIC_REAL_TYPE(T)
Definition: TypeTraits.h:85
vtkm::TypeTraitsRealTag
Tag used to identify types that store real (floating-point) numbers.
Definition: TypeTraits.h:28
vtkm::TypeTraits< vtkm::VecCConst< T > >::NumericTag
typename vtkm::TypeTraits< T >::NumericTag NumericTag
Definition: TypeTraits.h:149
vtkm::VecCConst
A const version of VecC.
Definition: Types.h:1331
vtkm::TypeTraits< vtkm::Pair< T, U > >::ZeroInitialization
static VTKM_EXEC_CONT vtkm::Pair< T, U > ZeroInitialization()
Definition: TypeTraits.h:177
vtkm::TypeTraits< vtkm::Vec< T, Size > >::NumericTag
typename vtkm::TypeTraits< T >::NumericTag NumericTag
Definition: TypeTraits.h:134
vtkm::TypeTraitsUnknownTag
Tag used to identify types that aren't Real, Integer, Scalar or Vector.
Definition: TypeTraits.h:20
vtkm::TypeTraitsScalarTag
Tag used to identify 0 dimensional types (scalars).
Definition: TypeTraits.h:44
vtkm::TypeTraitsVectorTag
Tag used to identify 1 dimensional types (vectors).
Definition: TypeTraits.h:51
vtkm::Vec
A short fixed-length array.
Definition: Types.h:767
vtkm::VecC
A Vec-like representation for short arrays.
Definition: Types.h:1237
vtkm::TypeTraits< vtkm::VecC< T > >::ZeroInitialization
static VTKM_EXEC_CONT vtkm::VecC< T > ZeroInitialization()
Definition: TypeTraits.h:165
vtkm::Pair
A vtkm::Pair is essentially the same as an STL pair object except that the methods (constructors and ...
Definition: Pair.h:29
vtkm::TypeTraits::ZeroInitialization
static VTKM_EXEC_CONT T ZeroInitialization()
Definition: TypeTraits.h:75