21 #ifndef __TBB_iterators_H 22 #define __TBB_iterators_H 29 #if __TBB_CPP11_DECLTYPE_PRESENT 33 template <
typename IntType>
81 #endif //__TBB_CPP11_DECLTYPE_PRESENT 83 #if __TBB_CPP11_PRESENT 85 #include <type_traits> 95 template<
typename TupleType,
typename DifferenceType>
96 static void increment(TupleType& it, DifferenceType forward) {
97 std::get<N-1>(it) += forward;
98 tuple_util<N-1>::increment(it, forward);
100 template<
typename TupleType,
typename DifferenceType>
101 static bool check_sync(
const TupleType& it1,
const TupleType& it2, DifferenceType val) {
102 if(std::get<N-1>(it1) - std::get<N-1>(it2) != val)
104 return tuple_util<N-1>::check_sync(it1, it2, val);
109 struct tuple_util<0> {
110 template<
typename TupleType,
typename DifferenceType>
111 static void increment(TupleType&, DifferenceType) {}
112 template<
typename TupleType,
typename DifferenceType>
113 static bool check_sync(
const TupleType&,
const TupleType&, DifferenceType) {
return true;}
116 template <
typename TupleReturnType>
117 struct make_references {
118 template <
typename TupleType, std::size_t... Is>
120 return std::tie((*std::get<Is>(t))...);
126 template <
typename... Types>
128 static const std::size_t num_types =
sizeof...(Types);
129 typedef typename std::tuple<Types...> it_types;
132 typedef std::tuple<typename std::iterator_traits<Types>::value_type...> value_type;
133 typedef std::tuple<typename std::iterator_traits<Types>::reference...> reference;
134 typedef std::tuple<typename std::iterator_traits<Types>::pointer...> pointer;
135 typedef std::random_access_iterator_tag iterator_category;
137 explicit zip_iterator(Types... args): my_it(std::make_tuple(args...)) {}
139 reference operator*() {
142 reference operator[](difference_type i)
const {
return *(*
this + i); }
144 difference_type
operator-(
const zip_iterator& it)
const {
145 __TBB_ASSERT(internal::tuple_util<num_types>::check_sync(my_it, it.my_it, std::get<0>(my_it) - std::get<0>(it.my_it)),
146 "Components of zip_iterator are not synchronous");
147 return std::get<0>(my_it) - std::get<0>(it.my_it);
150 zip_iterator& operator+=(difference_type forward) {
151 internal::tuple_util<num_types>::increment(my_it, forward);
154 zip_iterator& operator-=(difference_type backward) {
return *
this += -backward; }
155 zip_iterator& operator++() {
return *
this += 1; }
156 zip_iterator& operator--() {
return *
this -= 1; }
158 zip_iterator operator++(
int) {
159 zip_iterator it(*
this);
163 zip_iterator operator--(
int) {
164 zip_iterator it(*
this);
169 zip_iterator
operator-(difference_type backward)
const {
170 zip_iterator it(*
this);
171 return it -= backward;
173 zip_iterator
operator+(difference_type forward)
const {
174 zip_iterator it(*
this);
175 return it += forward;
177 friend zip_iterator
operator+(difference_type forward,
const zip_iterator& it) {
return it + forward; }
179 bool operator==(
const zip_iterator& it)
const {
180 return *
this - it == 0;
182 bool operator!=(
const zip_iterator& it)
const {
return !(*
this == it); }
183 bool operator<(
const zip_iterator& it)
const {
return *
this - it < 0; }
184 bool operator>(
const zip_iterator& it)
const {
return it < *
this; }
185 bool operator<=(
const zip_iterator& it)
const {
return !(*
this > it); }
186 bool operator>=(
const zip_iterator& it)
const {
return !(*
this < it); }
192 template<
typename... T>
193 zip_iterator<T...> make_zip_iterator(T... args) {
return zip_iterator<T...>(args...); }
197 #endif //__TBB_CPP11_PRESENT reference operator *() const
bool operator<(const concurrent_vector< T, A1 > &a, const concurrent_vector< T, A2 > &b)
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT p const __itt_domain __itt_id __itt_timestamp __itt_timestamp ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain ITT_FORMAT p const __itt_domain __itt_string_handle unsigned long long ITT_FORMAT lu const __itt_domain __itt_id __itt_string_handle __itt_metadata_type type
bool operator==(const cache_aligned_allocator< T > &, const cache_aligned_allocator< U > &)
counting_iterator operator+(difference_type forward) const
value_type operator[](difference_type i) const
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
bool operator<=(const concurrent_vector< T, A1 > &a, const concurrent_vector< T, A2 > &b)
counting_iterator operator++(int)
counting_iterator & operator-=(difference_type backward)
counting_iterator & operator+=(difference_type forward)
bool operator>(const counting_iterator &it) const
const IntType & reference
counting_iterator(IntType init)
counting_iterator operator--(int)
bool operator==(const counting_iterator &it) const
bool operator!=(const counting_iterator &it) const
friend counting_iterator operator+(difference_type forward, const counting_iterator it)
bool operator<=(const counting_iterator &it) const
std::random_access_iterator_tag iterator_category
counting_iterator operator-(difference_type backward) const
bool operator>(const concurrent_vector< T, A1 > &a, const concurrent_vector< T, A2 > &b)
bool operator!=(const cache_aligned_allocator< T > &, const cache_aligned_allocator< U > &)
decltype(IntType() -IntType()) typedef difference_type
vector_iterator< Container, T > operator+(ptrdiff_t offset, const vector_iterator< Container, T > &v)
counting_iterator & operator++()
bool operator>=(const concurrent_vector< T, A1 > &a, const concurrent_vector< T, A2 > &b)
bool operator>=(const counting_iterator &it) const
tick_count::interval_t operator-(const tick_count &t1, const tick_count &t0)
typename tbb::internal::make_index_sequence_impl< N >::type make_index_sequence
counting_iterator & operator--()
bool operator<(const counting_iterator &it) const
#define __TBB_STATIC_ASSERT(condition, msg)
difference_type operator-(const counting_iterator &it) const