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