18 #ifndef viskores_exec_cuda_internal_IteratorFromArrayPortal_h
19 #define viskores_exec_cuda_internal_IteratorFromArrayPortal_h
29 #include <thrust/functional.h>
30 #include <thrust/iterator/iterator_facade.h>
31 #include <thrust/system/cuda/execution_policy.h>
43 template <
class ArrayPortalType>
44 class IteratorFromArrayPortal
45 :
public ::thrust::iterator_facade<IteratorFromArrayPortal<ArrayPortalType>,
46 typename ArrayPortalType::ValueType,
47 ::thrust::system::cuda::tag,
48 ::thrust::random_access_traversal_tag,
49 viskores::internal::ArrayPortalValueReference<ArrayPortalType>,
54 IteratorFromArrayPortal()
61 explicit IteratorFromArrayPortal(
const ArrayPortalType& portal,
viskores::Id index = 0)
68 viskores::internal::ArrayPortalValueReference<ArrayPortalType> operator[](
69 std::ptrdiff_t idx)
const
71 return viskores::internal::ArrayPortalValueReference<ArrayPortalType>(
76 ArrayPortalType Portal;
80 friend class ::thrust::iterator_core_access;
83 viskores::internal::ArrayPortalValueReference<ArrayPortalType> dereference()
const
85 return viskores::internal::ArrayPortalValueReference<ArrayPortalType>(this->Portal,
90 bool equal(
const IteratorFromArrayPortal<ArrayPortalType>& other)
const
96 return (this->Index == other.Index);
100 void increment() { this->Index++; }
103 void decrement() { this->Index--; }
106 void advance(std::ptrdiff_t delta) { this->Index +=
static_cast<viskores::Id>(delta); }
109 std::ptrdiff_t distance_to(
const IteratorFromArrayPortal<ArrayPortalType>& other)
const
115 return static_cast<std::ptrdiff_t
>(other.Index - this->
Index);
136 template <
typename T>
137 struct is_non_const_reference;
139 template <
typename T>
140 struct is_non_const_reference<
viskores::internal::ArrayPortalValueReference<T>>
141 : thrust::detail::true_type
147 #endif //viskores_exec_cuda_internal_IteratorFromArrayPortal_h