VTK-m  2.2
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 
77  VTKM_EXEC_CONT static T ZeroInitialization() { return T(); }
78 };
79 
80 // Const types should have the same traits as their non-const counterparts.
81 //
82 template <typename T>
83 struct TypeTraits<const T> : TypeTraits<T>
84 {
85 };
86 
87 #define VTKM_BASIC_REAL_TYPE(T) \
88  template <> \
89  struct TypeTraits<T> \
90  { \
91  using NumericTag = TypeTraitsRealTag; \
92  using DimensionalityTag = TypeTraitsScalarTag; \
93  VTKM_EXEC_CONT static T ZeroInitialization() { return T(); } \
94  };
95 
96 #define VTKM_BASIC_INTEGER_TYPE(T) \
97  template <> \
98  struct TypeTraits<T> \
99  { \
100  using NumericTag = TypeTraitsIntegerTag; \
101  using DimensionalityTag = TypeTraitsScalarTag; \
102  VTKM_EXEC_CONT static T ZeroInitialization() \
103  { \
104  using ReturnType = T; \
105  return ReturnType(); \
106  } \
107  };
108 
111 
114 
120 VTKM_BASIC_INTEGER_TYPE(unsigned short)
126 VTKM_BASIC_INTEGER_TYPE(unsigned long long)
127 
128 #undef VTKM_BASIC_REAL_TYPE
129 #undef VTKM_BASIC_INTEGER_TYPE
130 
133 template <typename T, vtkm::IdComponent Size>
134 struct TypeTraits<vtkm::Vec<T, Size>>
135 {
138 
141  {
143  }
144 };
145 
148 template <typename T>
150 {
153 
156 };
157 
160 template <typename T>
161 struct TypeTraits<vtkm::VecC<T>>
162 {
165 
168 };
169 
172 template <typename T, typename U>
173 struct TypeTraits<vtkm::Pair<T, U>>
174 {
177 
180  {
183  }
184 };
185 
186 } // namespace vtkm
187 
188 #endif //vtk_m_TypeTraits_h
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:163
VTKM_BASIC_INTEGER_TYPE
#define VTKM_BASIC_INTEGER_TYPE(T)
Definition: TypeTraits.h:96
VTKM_BASIC_REAL_TYPE
#define VTKM_BASIC_REAL_TYPE(T)
Definition: TypeTraits.h:87
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:151
vtkm::VecCConst
A const version of VecC.
Definition: Types.h:363
vtkm::TypeTraits< vtkm::Pair< T, U > >::ZeroInitialization
static vtkm::Pair< T, U > ZeroInitialization()
Definition: TypeTraits.h:179
vtkm::TypeTraits< vtkm::Vec< T, Size > >::NumericTag
typename vtkm::TypeTraits< T >::NumericTag NumericTag
Definition: TypeTraits.h:136
vtkm::TypeTraits< vtkm::VecC< T > >::ZeroInitialization
static vtkm::VecC< T > ZeroInitialization()
Definition: TypeTraits.h:167
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:357
vtkm::TypeTraits< vtkm::Vec< T, Size > >::ZeroInitialization
static vtkm::Vec< T, Size > ZeroInitialization()
Definition: TypeTraits.h:140
vtkm::TypeTraits::ZeroInitialization
static T ZeroInitialization()
A static function that returns 0 (or the closest equivalent to it) for the given type.
Definition: TypeTraits.h:77
vtkm::VecC
A Vec-like representation for short arrays.
Definition: Types.h:360
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< vtkm::VecCConst< T > >::ZeroInitialization
static vtkm::VecCConst< T > ZeroInitialization()
Definition: TypeTraits.h:155