8#ifndef MULTI_ARRAY_ITERATOR_OPENFPM_HPP_
9#define MULTI_ARRAY_ITERATOR_OPENFPM_HPP_
18#include "boost/iterator/iterator_facade.hpp"
23#include "util/cuda_util.hpp"
33 T* operator->()
const {
return &value_; }
36 operator T*()
const {
return &value_; }
44template <
typename T,
typename TPtr,
typename NumDims,
typename vector,
typename Reference,
45 typename IteratorCategory>
48template <
typename T,
typename TPtr,
typename NumDims,
typename vector,
typename Reference,
49 typename IteratorCategory>
52 boost::iterator_facade<
53 array_iterator_openfpm<T,TPtr,NumDims,vector,Reference,IteratorCategory>
54 , typename associated_types_openfpm<T,NumDims,vector>::value_type
61 friend class iterator_core_access;
64 typedef boost::iterator_facade<
67 , boost::random_access_traversal_tag
71 typedef typename access_t::index index;
72 typedef typename access_t::size_type size_type;
74#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
75 template <
typename,
typename,
typename,
typename,
typename,
typename>
83 const size_type extent;
84 const index* strides_;
88 typedef typename facade_type::reference reference;
89 typedef typename facade_type::value_type value_type;
90 typedef typename facade_type::difference_type difference_type;
94 __device__ __host__
array_iterator_openfpm(index idx,TPtr base,
const size_type extent,
const index* strides)
95 :idx_(idx), base_(base), extent(extent),strides_(strides)
98 template <
typename OPtr,
typename ORef,
typename Cat>
101 ,
typename boost::enable_if_convertible<OPtr,TPtr>::type* = 0
103 : idx_(rhs.idx_), base_(rhs.base_), extent(rhs.extent),strides_(rhs.strides_)
115 reference dereference()
const
117 typedef typename value_accessor_generator_openfpm<T,NumDims,vector>::type accessor;
118 return accessor::access(boost::type<reference>(),
124 void increment() { ++idx_; }
125 void decrement() { --idx_; }
127 template <
class IteratorAdaptor>
128 bool equal(IteratorAdaptor& rhs)
const {
129 const std::size_t N = NumDims::value;
130 return (idx_ == rhs.idx_) &&
131 (base_ == rhs.base_) &&
132 (extent == rhs.extent) &&
133 ( (strides_ == rhs.strides_) ||
134 std::equal(strides_,strides_+N,rhs.strides_) );
137 template <
class DifferenceType>
138 void advance(DifferenceType n) {
142 template <
class IteratorAdaptor>
143 typename facade_type::difference_type
144 distance_to(IteratorAdaptor& rhs)
const {
145 return rhs.idx_ - idx_;
This class is a trick to indicate the compiler a specific specialization pattern.
Implementation of 1-D std::vector like structure.
convert a type into constant type