VTK-m  2.0
ArrayPortalHelpers.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_internal_ArrayPortalHelpers_h
11 #define vtk_m_internal_ArrayPortalHelpers_h
12 
13 
14 #include <vtkm/VecTraits.h>
16 
17 namespace vtkm
18 {
19 namespace internal
20 {
21 
22 namespace detail
23 {
24 
25 template <typename PortalType>
26 struct PortalSupportsGetsImpl
27 {
28  template <typename U, typename S = decltype(std::declval<U>().Get(vtkm::Id{}))>
29  static std::true_type has(int);
30  template <typename U>
31  static std::false_type has(...);
32  using type = decltype(has<PortalType>(0));
33 };
34 
35 template <typename PortalType>
36 struct PortalSupportsGets3DImpl
37 {
38  template <typename U, typename S = decltype(std::declval<U>().Get(vtkm::Id3{}))>
39  static std::true_type has(int);
40  template <typename U>
41  static std::false_type has(...);
42  using type = decltype(has<PortalType>(0));
43 };
44 
45 template <typename PortalType>
46 struct PortalSupportsSetsImpl
47 {
48  template <typename U,
49  typename S = decltype(std::declval<U>().Set(vtkm::Id{},
50  std::declval<typename U::ValueType>()))>
51  static std::true_type has(int);
52  template <typename U>
53  static std::false_type has(...);
54  using type = decltype(has<PortalType>(0));
55 };
56 
57 template <typename PortalType>
58 struct PortalSupportsSets3DImpl
59 {
60  template <typename U,
61  typename S = decltype(std::declval<U>().Set(vtkm::Id3{},
62  std::declval<typename U::ValueType>()))>
63  static std::true_type has(int);
64  template <typename U>
65  static std::false_type has(...);
66  using type = decltype(has<PortalType>(0));
67 };
68 
69 template <typename PortalType>
70 struct PortalSupportsIteratorsImpl
71 {
72  template <typename U, typename S = decltype(std::declval<U>().GetIteratorBegin())>
73  static std::true_type has(int);
74  template <typename U>
75  static std::false_type has(...);
76  using type = decltype(has<PortalType>(0));
77 };
78 
79 } // namespace detail
80 
81 template <typename PortalType>
82 using PortalSupportsGets =
83  typename detail::PortalSupportsGetsImpl<typename std::decay<PortalType>::type>::type;
84 
85 template <typename PortalType>
86 using PortalSupportsGets3D =
87  typename detail::PortalSupportsGets3DImpl<typename std::decay<PortalType>::type>::type;
88 
89 template <typename PortalType>
90 using PortalSupportsSets =
91  typename detail::PortalSupportsSetsImpl<typename std::decay<PortalType>::type>::type;
92 
93 template <typename PortalType>
94 using PortalSupportsSets3D =
95  typename detail::PortalSupportsSets3DImpl<typename std::decay<PortalType>::type>::type;
96 
97 template <typename PortalType>
98 using PortalSupportsIterators =
99  typename detail::PortalSupportsIteratorsImpl<typename std::decay<PortalType>::type>::type;
100 }
101 } // namespace vtkm::internal
102 
103 #endif //vtk_m_internal_ArrayPortalHelpers_h
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
vtkm::Id
vtkm::Int32 Id
Represents an ID (index into arrays).
Definition: Types.h:191
ExportMacros.h
vtkm::Vec< vtkm::Id, 3 >
VecTraits.h