31#ifndef ETL_ITERATOR_INCLUDED
32#define ETL_ITERATOR_INCLUDED
39#if ETL_USING_STL || defined(ETL_IN_UNIT_TEST)
61 template <typename TIterator, typename = typename etl::enable_if<!etl::is_fundamental<TIterator>::value,
void>
::type>
64 typedef typename TIterator::iterator_category iterator_category;
65 typedef typename TIterator::value_type value_type;
66 typedef typename TIterator::difference_type difference_type;
67 typedef typename TIterator::pointer pointer;
68 typedef typename TIterator::reference reference;
75 typedef ETL_OR_STD::random_access_iterator_tag iterator_category;
77 typedef ptrdiff_t difference_type;
78 typedef typename etl::remove_cv<T>::type* pointer;
86 typedef ETL_OR_STD::random_access_iterator_tag iterator_category;
88 typedef ptrdiff_t difference_type;
89 typedef const typename etl::remove_cv<T>::type* pointer;
90 typedef const T& reference;
95 template <
typename TIterator,
typename TDistance>
96 ETL_CONSTEXPR14
void advance_helper(TIterator& itr, TDistance n, ETL_OR_STD::output_iterator_tag)
104 template <
typename TIterator,
typename TDistance>
105 ETL_CONSTEXPR14
void advance_helper(TIterator& itr, TDistance n, ETL_OR_STD::forward_iterator_tag)
113 template <
typename TIterator,
typename TDistance>
114 ETL_CONSTEXPR14
void advance_helper(TIterator& itr, TDistance n, ETL_OR_STD::bidirectional_iterator_tag)
132 template <
typename TIterator,
typename TDistance>
133 ETL_CONSTEXPR14
void advance_helper(TIterator& itr, TDistance n, ETL_OR_STD::random_access_iterator_tag)
138 template <
typename TIterator,
typename TDistance>
139 ETL_CONSTEXPR14
void advance(TIterator& itr, TDistance n)
141 typedef typename etl::iterator_traits<TIterator>::iterator_category tag;
143 advance_helper(itr, n, tag());
148 template<
typename TIterator>
149 ETL_CONSTEXPR14
typename etl::iterator_traits<TIterator>::difference_type distance_helper(TIterator first, TIterator last, ETL_OR_STD::input_iterator_tag)
151 typename etl::iterator_traits<TIterator>::difference_type d = 0;
153 while (first != last)
162 template<
typename TIterator>
163 ETL_CONSTEXPR14
typename etl::iterator_traits<TIterator>::difference_type distance_helper(TIterator first, TIterator last, ETL_OR_STD::forward_iterator_tag)
165 typename etl::iterator_traits<TIterator>::difference_type d = 0;
167 while (first != last)
176 template<
typename TIterator>
177 ETL_CONSTEXPR14
typename etl::iterator_traits<TIterator>::difference_type distance_helper(TIterator first, TIterator last, ETL_OR_STD::bidirectional_iterator_tag)
179 typename etl::iterator_traits<TIterator>::difference_type d = 0;
181 while (first != last)
190 template<
typename TIterator>
191 ETL_CONSTEXPR14
typename etl::iterator_traits<TIterator>::difference_type distance_helper(TIterator first, TIterator last, ETL_OR_STD::random_access_iterator_tag)
196 template<
typename TIterator>
197 ETL_CONSTEXPR14
typename etl::iterator_traits<TIterator>::difference_type distance(TIterator first, TIterator last)
199 typedef typename etl::iterator_traits<TIterator>::iterator_category tag;
201 return distance_helper(first, last, tag());
206 template<
typename TIterator>
207 ETL_CONSTEXPR14 TIterator prev(TIterator itr,
typename etl::iterator_traits<TIterator>::difference_type n = 1)
209 etl::advance(itr, -n);
216 template<
typename TIterator>
217 ETL_CONSTEXPR14 TIterator next(TIterator itr,
typename etl::iterator_traits<TIterator>::difference_type n = 1)
219 etl::advance(itr, n);
226 template <
typename TIterator>
227 class reverse_iterator
231 typedef typename iterator_traits<TIterator>::iterator_category iterator_category;
232 typedef typename iterator_traits<TIterator>::value_type value_type;
233 typedef typename iterator_traits<TIterator>::difference_type difference_type;
234 typedef typename iterator_traits<TIterator>::pointer pointer;
235 typedef typename iterator_traits<TIterator>::reference reference;
237 typedef TIterator iterator_type;
239 ETL_CONSTEXPR14 reverse_iterator()
244 ETL_CONSTEXPR14
explicit reverse_iterator(TIterator itr)
249 template <
typename TOther>
250 ETL_CONSTEXPR14 reverse_iterator(
const reverse_iterator<TOther>& other)
251 : current(other.base())
255 template<
class TOther>
256 ETL_CONSTEXPR14 reverse_iterator& operator =(
const reverse_iterator<TOther>& other)
258 current = other.base();
263 ETL_CONSTEXPR14 TIterator base()
const
268 ETL_NODISCARD ETL_CONSTEXPR14 reference operator*()
const
270 TIterator temp = current;
275 ETL_NODISCARD ETL_CONSTEXPR14 pointer operator->()
const
277 TIterator temp = current;
282 ETL_CONSTEXPR14 reverse_iterator& operator++()
289 ETL_CONSTEXPR14 reverse_iterator operator++(
int)
291 reverse_iterator temp = *
this;
297 ETL_CONSTEXPR14 reverse_iterator& operator--()
304 ETL_CONSTEXPR14 reverse_iterator operator--(
int)
306 reverse_iterator temp = *
this;
312 ETL_CONSTEXPR14 reverse_iterator& operator+=(
const difference_type offset)
319 ETL_CONSTEXPR14 reverse_iterator& operator-=(
const difference_type offset)
326 ETL_NODISCARD ETL_CONSTEXPR14 reverse_iterator operator+(
const difference_type offset)
const
328 return reverse_iterator(current - offset);
331 ETL_NODISCARD ETL_CONSTEXPR14 reverse_iterator operator-(
const difference_type offset)
const
333 return (reverse_iterator(current + offset));
336 ETL_NODISCARD ETL_CONSTEXPR14 reference operator[](
const difference_type offset)
const
338 return (*(*
this + offset));
346 template <
typename TIterator>
349 return lhs.base() == rhs.base();
352 template <
typename TIterator>
353 ETL_CONSTEXPR14
bool operator !=(
const reverse_iterator<TIterator>& lhs,
const reverse_iterator<TIterator>& rhs)
355 return !(lhs == rhs);
358 template <
typename TIterator>
361 return rhs.base() < lhs.base();
364 template <
typename TIterator>
370 template <
typename TIterator>
376 template <
typename TIterator>
382 template <
typename TIterator>
385 return rhs.base() - lhs.base();
388 template <
typename TIterator,
class TDifference>
391 return itr.operator +(n);
397 template <
typename TCategory,
typename T,
typename TDistance = ptrdiff_t,
typename TPo
inter = T* ,
typename TReference = T& >
400 typedef T value_type;
401 typedef TDistance difference_type;
402 typedef TPointer pointer;
403 typedef TReference reference;
404 typedef TCategory iterator_category;
410 template <
typename TIterator>
415 typedef typename iterator_traits<TIterator>::iterator_category
iterator_category;
416 typedef typename iterator_traits<TIterator>::value_type
value_type;
417 typedef typename iterator_traits<TIterator>::difference_type
difference_type;
418 typedef TIterator iterator_type;
426 explicit move_iterator(TIterator itr)
431 template <
typename U>
432 move_iterator(
const move_iterator<U>& itr)
433 : current(itr.base())
437 template <
typename U>
438 move_iterator& operator =(
const move_iterator<U>& itr)
440 current = itr.current;
444 iterator_type base()
const
449 pointer operator ->()
const
454 reference operator *()
const
456 return etl::move(*current);
459 move_iterator& operator++()
465 move_iterator& operator--()
471 move_iterator operator++(
int)
473 move_iterator temp = *
this;
478 move_iterator operator--(
int)
480 move_iterator temp = *
this;
485 move_iterator operator +(difference_type n)
const
487 return move_iterator(current + n);
490 move_iterator operator -(difference_type n)
const
492 return move_iterator(current - n);
495 move_iterator operator +=(difference_type n)
501 move_iterator operator -=(difference_type n)
507 reference operator [](difference_type n)
const
509 return etl::move(current[n]);
517 template <
typename TIterator>
518 bool operator ==(
const etl::move_iterator<TIterator>& lhs,
519 const etl::move_iterator<TIterator>& rhs)
521 return lhs.base() == rhs.base();
524 template <
typename TIterator>
525 bool operator !=(
const etl::move_iterator<TIterator>& lhs,
526 const etl::move_iterator<TIterator>& rhs)
528 return !(lhs == rhs);
531 template <
typename TIterator>
532 bool operator <(
const etl::move_iterator<TIterator>& lhs,
533 const etl::move_iterator<TIterator>& rhs)
535 return lhs.base() < rhs.base();
538 template <
typename TIterator>
539 bool operator <=(
const etl::move_iterator<TIterator>& lhs,
540 const etl::move_iterator<TIterator>& rhs)
545 template <
typename TIterator>
546 bool operator >(
const etl::move_iterator<TIterator>& lhs,
547 const etl::move_iterator<TIterator>& rhs)
552 template <
typename TIterator>
553 bool operator >=(
const etl::move_iterator<TIterator>& lhs,
554 const etl::move_iterator<TIterator>& rhs)
559 template <
typename TIterator>
560 move_iterator<TIterator>
operator +(
typename move_iterator<TIterator>::difference_type n,
561 const move_iterator<TIterator>& rhs)
566 template <
typename TIterator1,
typename TIterator2 >
567 auto operator -(
const move_iterator<TIterator1>& lhs,
568 const move_iterator<TIterator2>& rhs) ->
decltype(lhs.base() - rhs.base())
570 return lhs.base() - rhs.base();
573 template <
typename TIterator>
574 etl::move_iterator<TIterator> make_move_iterator(TIterator itr)
576 return etl::move_iterator<TIterator>(itr);
588 template <
typename TContainer>
593 typedef TContainer container_type;
608 container->push_back(value);
619 container->push_back(etl::move(value));
651 TContainer* container;
657 template <
typename TContainer>
672 template <
typename TContainer>
677 typedef TContainer container_type;
692 container->push_front(value);
702 container->push_front(etl::move(value));
733 TContainer* container;
739 template <
typename TContainer>
754 template <
typename TContainer>
759 typedef TContainer container_type;
774 container->push(value);
785 container->push(etl::move(value));
817 TContainer* container;
823 template <
typename TContainer>
834 template <
typename T>
840 template <
typename T>
841 ETL_CONSTANT
bool is_input_iterator<T>::value;
843 template <
typename T>
849 template <
typename T>
850 ETL_CONSTANT
bool is_output_iterator<T>::value;
852 template <
typename T>
858 template <
typename T>
859 ETL_CONSTANT
bool is_forward_iterator<T>::value;
861 template <
typename T>
867 template <
typename T>
868 ETL_CONSTANT
bool is_bidirectional_iterator<T>::value;
871 template <
typename T>
877 template <
typename T>
878 ETL_CONSTANT
bool is_random_iterator<T>::value;
880 template <
typename T>
886 template <
typename T>
887 ETL_CONSTANT
bool is_random_access_iterator<T>::value;
889 template <
typename T>
892 static ETL_CONSTANT
bool value = etl::is_input_iterator<T>::value ||
893 etl::is_forward_iterator<T>::value ||
894 etl::is_bidirectional_iterator<T>::value ||
895 etl::is_random_iterator<T>::value;
898 template <
typename T>
899 ETL_CONSTANT
bool is_input_iterator_concept<T>::value;
901 template <
typename T>
904 static ETL_CONSTANT
bool value = etl::is_output_iterator<T>::value ||
905 etl::is_forward_iterator<T>::value ||
906 etl::is_bidirectional_iterator<T>::value ||
907 etl::is_random_iterator<T>::value;
910 template <
typename T>
911 ETL_CONSTANT
bool is_output_iterator_concept<T>::value;
913 template <
typename T>
916 static ETL_CONSTANT
bool value = etl::is_forward_iterator<T>::value ||
917 etl::is_bidirectional_iterator<T>::value ||
918 etl::is_random_iterator<T>::value;
921 template <
typename T>
922 ETL_CONSTANT
bool is_forward_iterator_concept<T>::value;
924 template <
typename T>
927 static ETL_CONSTANT
bool value = etl::is_bidirectional_iterator<T>::value ||
928 etl::is_random_iterator<T>::value;
931 template <
typename T>
932 ETL_CONSTANT
bool is_bidirectional_iterator_concept<T>::value;
935 template <
typename T>
938 static ETL_CONSTANT
bool value = etl::is_random_iterator<T>::value;
942 template <
typename T>
943 ETL_CONSTANT
bool is_random_iterator_concept<T>::value;
946 template <
typename T>
949 static ETL_CONSTANT
bool value = etl::is_random_access_iterator<T>::value;
953 template <
typename T>
954 ETL_CONSTANT
bool is_random_access_iterator_concept<T>::value;
956#if ETL_NOT_USING_STL || ETL_CPP11_NOT_SUPPORTED
961 template<
typename TContainer>
962 ETL_CONSTEXPR
typename TContainer::iterator
begin(TContainer& container)
964 return container.begin();
971 template<
typename TContainer>
972 ETL_CONSTEXPR
typename TContainer::const_iterator
begin(
const TContainer& container)
974 return container.begin();
981 template<
typename TContainer>
982 ETL_CONSTEXPR
typename TContainer::const_iterator
cbegin(
const TContainer& container)
984 return container.cbegin();
991 template<
typename TContainer>
992 ETL_CONSTEXPR
typename TContainer::iterator
end(TContainer& container)
994 return container.end();
1001 template<
typename TContainer>
1002 ETL_CONSTEXPR
typename TContainer::const_iterator
end(
const TContainer& container)
1004 return container.end();
1011 template<
typename TContainer>
1012 ETL_CONSTEXPR
typename TContainer::const_iterator
cend(
const TContainer& container)
1014 return container.cend();
1021 template<
typename TValue,
size_t Array_Size>
1022 ETL_CONSTEXPR TValue*
begin(TValue(&data)[Array_Size])
1031 template<
typename TValue,
size_t Array_Size>
1032 ETL_CONSTEXPR
const TValue*
begin(
const TValue(&data)[Array_Size])
1041 template<
typename TValue,
size_t Array_Size>
1042 ETL_CONSTEXPR
const TValue*
cbegin(
const TValue(&data)[Array_Size])
1051 template<
typename TValue,
size_t Array_Size>
1052 ETL_CONSTEXPR TValue*
end(TValue(&data)[Array_Size])
1054 return &data[Array_Size];
1061 template<
typename TValue,
size_t Array_Size>
1062 ETL_CONSTEXPR
const TValue*
end(
const TValue(&data)[Array_Size])
1064 return &data[Array_Size];
1071 template<
typename TValue,
size_t Array_Size>
1072 ETL_CONSTEXPR
const TValue*
cend(
const TValue(&data)[Array_Size])
1074 return &data[Array_Size];
1078#if ETL_NOT_USING_STL || ETL_CPP14_NOT_SUPPORTED
1083 template<
typename TContainer>
1084 ETL_CONSTEXPR
typename TContainer::reverse_iterator
rbegin(TContainer& container)
1086 return container.rbegin();
1093 template<
typename TContainer>
1094 ETL_CONSTEXPR
typename TContainer::const_reverse_iterator
rbegin(
const TContainer& container)
1096 return container.rbegin();
1103 template<
typename TContainer>
1104 ETL_CONSTEXPR
typename TContainer::const_reverse_iterator
crbegin(
const TContainer& container)
1106 return container.crbegin();
1113 template<
typename TContainer>
1114 ETL_CONSTEXPR
typename TContainer::reverse_iterator
rend(TContainer& container)
1116 return container.rend();
1123 template<
typename TContainer>
1124 ETL_CONSTEXPR
typename TContainer::const_reverse_iterator
rend(
const TContainer& container)
1126 return container.rend();
1133 template<
typename TContainer>
1134 ETL_CONSTEXPR
typename TContainer::const_reverse_iterator
crend(
const TContainer& container)
1136 return container.crend();
1143 template<
typename TValue,
size_t Array_Size>
1144 ETL_OR_STD::reverse_iterator<TValue*>
rbegin(TValue(&data)[Array_Size])
1146 return ETL_OR_STD::reverse_iterator<TValue*>(&data[Array_Size]);
1153 template<
typename TValue,
size_t Array_Size>
1154 ETL_CONSTEXPR ETL_OR_STD::reverse_iterator<const TValue*>
crbegin(
const TValue(&data)[Array_Size])
1156 return ETL_OR_STD::reverse_iterator<const TValue*>(&data[Array_Size]);
1163 template<
typename TValue,
size_t Array_Size>
1164 ETL_CONSTEXPR ETL_OR_STD::reverse_iterator<TValue*>
rend(TValue(&data)[Array_Size])
1166 return ETL_OR_STD::reverse_iterator<TValue*>(&data[0]);
1173 template<
typename TValue,
size_t Array_Size>
1174 ETL_CONSTEXPR ETL_OR_STD::reverse_iterator<const TValue*>
crend(
const TValue(&data)[Array_Size])
1176 return ETL_OR_STD::reverse_iterator<const TValue*>(&data[0]);
1180#if ETL_NOT_USING_STL || ETL_CPP17_NOT_SUPPORTED
1186 template<
typename TContainer>
1187 ETL_CONSTEXPR
typename TContainer::size_type
size(
const TContainer& container)
1189 return container.size();
1196 template<
typename TValue,
size_t Array_Size>
1197 ETL_CONSTEXPR
size_t size(TValue(&)[Array_Size])
1210 template <
typename T,
size_t Array_Size>
1213#define ETL_ARRAY_SIZE(a) sizeof(etl::array_size(a))
Turns assignment into push_back.
Definition iterator.h:590
ETL_CONSTEXPR14 back_insert_iterator & operator++()
Pre-increment operator.
Definition iterator.h:636
ETL_CONSTEXPR14 back_insert_iterator(TContainer &c)
Constructor.
Definition iterator.h:598
ETL_CONSTEXPR14 back_insert_iterator & operator=(const typename TContainer::value_type &value)
Assignment operator.
Definition iterator.h:606
ETL_NODISCARD ETL_CONSTEXPR14 back_insert_iterator & operator*()
Dereference operator.
Definition iterator.h:628
Turns assignment into a push_front.
Definition iterator.h:674
ETL_CONSTEXPR14 front_insert_iterator(TContainer &c)
Constructor.
Definition iterator.h:682
ETL_CONSTEXPR14 front_insert_iterator & operator++()
Pre-increment operator.
Definition iterator.h:718
ETL_NODISCARD ETL_CONSTEXPR14 front_insert_iterator & operator*()
Dereference operator.
Definition iterator.h:710
ETL_CONSTEXPR14 front_insert_iterator & operator=(const typename TContainer::value_type &value)
Assignment operator.
Definition iterator.h:690
Turns assignment into a push.
Definition iterator.h:756
ETL_NODISCARD ETL_CONSTEXPR14 push_insert_iterator & operator*()
Dereference operator.
Definition iterator.h:794
ETL_CONSTEXPR14 push_insert_iterator & operator=(const typename TContainer::value_type &value)
Assignment operator.
Definition iterator.h:772
ETL_CONSTEXPR14 push_insert_iterator & operator++()
Pre-increment operator.
Definition iterator.h:802
ETL_CONSTEXPR14 push_insert_iterator(TContainer &c)
Constructor.
Definition iterator.h:764
Definition iterator.h:228
ETL_CONSTEXPR17 etl::enable_if<!etl::is_same< T, etl::nullptr_t >::value, T >::type * addressof(T &t)
Definition addressof.h:52
is_same
Definition type_traits_generator.h:1104
bitset_ext
Definition absolute.h:39
ETL_CONSTEXPR TContainer::reverse_iterator rend(TContainer &container)
Definition iterator.h:1114
ETL_CONSTEXPR TContainer::const_reverse_iterator crbegin(const TContainer &container)
Definition iterator.h:1104
ETL_CONSTEXPR14 etl::circular_iterator< TIterator > operator-(etl::circular_iterator< TIterator > &lhs, typename etl::iterator_traits< TIterator >::difference_type offset)
Definition circular_iterator.h:672
bool operator>(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1190
ETL_NODISCARD ETL_CONSTEXPR14 etl::push_insert_iterator< TContainer > push_inserter(TContainer &container)
Creates a push_insert_iterator from a container.
Definition iterator.h:826
ETL_NODISCARD ETL_CONSTEXPR14 etl::front_insert_iterator< TContainer > front_inserter(TContainer &container)
Creates a front_insert_iterator from a container.
Definition iterator.h:742
char(& array_size(T(&array)[Array_Size]))[Array_Size]
ETL_CONSTEXPR TContainer::reverse_iterator rbegin(TContainer &container)
Definition iterator.h:1084
bool operator>=(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1202
ETL_CONSTEXPR TContainer::const_iterator cbegin(const TContainer &container)
Definition iterator.h:982
bool operator!=(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1151
ETL_NODISCARD ETL_CONSTEXPR14 etl::back_insert_iterator< TContainer > back_inserter(TContainer &container)
Creates a back_insert_iterator from a container.
Definition iterator.h:660
ETL_CONSTEXPR TContainer::size_type size(const TContainer &container)
Definition iterator.h:1187
bool operator==(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1139
ETL_CONSTEXPR TContainer::iterator begin(TContainer &container)
Definition iterator.h:962
ETL_CONSTEXPR14 etl::circular_iterator< TIterator > operator+(etl::circular_iterator< TIterator > &lhs, typename etl::iterator_traits< TIterator >::difference_type offset)
Definition circular_iterator.h:659
ETL_CONSTEXPR TContainer::const_reverse_iterator crend(const TContainer &container)
Definition iterator.h:1134
ETL_CONSTEXPR TContainer::const_iterator cend(const TContainer &container)
Definition iterator.h:1012
bool operator<(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1163
bool operator<=(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1178
ETL_CONSTEXPR TContainer::iterator end(TContainer &container)
Definition iterator.h:992
Definition iterator.h:926
Definition iterator.h:863
Definition iterator.h:915
Definition iterator.h:854
Definition iterator.h:903
Definition iterator.h:845
Definition iterator.h:948
Definition iterator.h:882
Definition iterator.h:937
Definition iterator.h:873
iterator
Definition iterator.h:399