Embedded Template Library 1.0
Loading...
Searching...
No Matches
fixed_iterator.h
Go to the documentation of this file.
1
2
3/******************************************************************************
4The MIT License(MIT)
5
6Embedded Template Library.
7https://github.com/ETLCPP/etl
8https://www.etlcpp.com
9
10Copyright(c) 2015 John Wellbelove
11
12Permission is hereby granted, free of charge, to any person obtaining a copy
13of this software and associated documentation files(the "Software"), to deal
14in the Software without restriction, including without limitation the rights
15to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
16copies of the Software, and to permit persons to whom the Software is
17furnished to do so, subject to the following conditions :
18
19The above copyright notice and this permission notice shall be included in all
20copies or substantial portions of the Software.
21
22THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
25AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28SOFTWARE.
29******************************************************************************/
30
31#ifndef ETL_FIXED_ITERATOR_INCLUDED
32#define ETL_FIXED_ITERATOR_INCLUDED
33
34#include "platform.h"
35#include "iterator.h"
36
38
39namespace etl
40{
46 template <typename TIterator>
48 : etl::iterator<typename etl::iterator_traits<TIterator>::iterator_category, typename etl::iterator_traits<TIterator>::value_type>
49 {
50 public:
51
52 //***************************************************************************
54 //***************************************************************************
55 ETL_CONSTEXPR fixed_iterator()
56 : it(TIterator())
57 {
58 }
59
60 //***************************************************************************
62 //***************************************************************************
63 ETL_CONSTEXPR fixed_iterator(TIterator it_)
64 : it(it_)
65 {
66 }
67
68 //***************************************************************************
70 //***************************************************************************
71 ETL_CONSTEXPR fixed_iterator(const fixed_iterator& other)
72 : it(other.it)
73 {
74 }
75
76 //***************************************************************************
78 //***************************************************************************
79 ETL_CONSTEXPR14 fixed_iterator& operator++()
80 {
81 return *this;
82 }
83
84 //***************************************************************************
86 //***************************************************************************
87 ETL_CONSTEXPR14 fixed_iterator operator++(int)
88 {
89 return *this;
90 }
91
92 //***************************************************************************
94 //***************************************************************************
95 ETL_CONSTEXPR14 fixed_iterator& operator--()
96 {
97 return *this;
98 }
99
100 //***************************************************************************
102 //***************************************************************************
103 ETL_CONSTEXPR14 fixed_iterator operator--(int)
104 {
105 return *this;
106 }
107
108 //***************************************************************************
110 //***************************************************************************
111 ETL_CONSTEXPR14 typename etl::iterator_traits<TIterator>::reference operator*()
112 {
113 return *it;
114 }
115
116 //***************************************************************************
118 //***************************************************************************
119 ETL_CONSTEXPR typename etl::iterator_traits<TIterator>::reference operator*() const
120 {
121 return *it;
122 }
123
124 //***************************************************************************
126 //***************************************************************************
127 ETL_CONSTEXPR14 TIterator operator->()
128 {
129 return it;
130 }
131
132 //***************************************************************************
134 //***************************************************************************
135 ETL_CONSTEXPR const TIterator operator->() const
136 {
137 return it;
138 }
139
140 //***************************************************************************
142 //***************************************************************************
143 ETL_CONSTEXPR operator TIterator() const
144 {
145 return it;
146 }
147
148 //***************************************************************************
150 //***************************************************************************
151 ETL_CONSTEXPR14 fixed_iterator& operator+=(typename etl::iterator_traits<TIterator>::difference_type /*offset*/)
152 {
153 return *this;
154 }
155
156 //***************************************************************************
158 //***************************************************************************
159 ETL_CONSTEXPR14 fixed_iterator& operator-=(typename etl::iterator_traits<TIterator>::difference_type /*offset*/)
160 {
161 return *this;
162 }
163
164 //***************************************************************************
166 //***************************************************************************
167 ETL_CONSTEXPR14 fixed_iterator& operator=(TIterator new_it)
168 {
169 it = new_it;
170 return *this;
171 }
172
173 //***************************************************************************
175 //***************************************************************************
177 {
178 it = other.it;
179 return *this;
180 }
181
182 private:
183
184 TIterator it;
185 };
186
187 //*****************************************************************************
189 //*****************************************************************************
190 template <typename TIterator>
192 typename etl::iterator_traits<TIterator>::difference_type /*rhs*/)
193 {
194 return lhs;
195 }
196
197 //*****************************************************************************
199 //*****************************************************************************
200 template <typename TIterator>
202 typename etl::iterator_traits<TIterator>::difference_type /*rhs*/)
203 {
204 return lhs;
205 }
206
207 //*****************************************************************************
209 //*****************************************************************************
210 template <typename TIterator>
211 ETL_CONSTEXPR typename etl::iterator_traits<TIterator>::difference_type operator-(const etl::fixed_iterator<TIterator>& lhs,
213 {
214 return TIterator(lhs) - TIterator(rhs);
215 }
216
217 //*****************************************************************************
219 //*****************************************************************************
220 template <typename TIterator>
222 {
223 return TIterator(lhs) == TIterator(rhs);
224 }
225
226 //*****************************************************************************
228 //*****************************************************************************
229 template <typename TIterator>
230 ETL_CONSTEXPR bool operator==(const etl::fixed_iterator<TIterator>& lhs, TIterator rhs)
231 {
232 return TIterator(lhs) == rhs;
233 }
234
235 //*****************************************************************************
237 //*****************************************************************************
238 template <typename TIterator>
239 ETL_CONSTEXPR bool operator==(TIterator lhs, const etl::fixed_iterator<TIterator>& rhs)
240 {
241 return lhs == TIterator(rhs);
242 }
243
244 //*****************************************************************************
246 //*****************************************************************************
247 template <typename TIterator>
249 {
250 return !(lhs == rhs);
251 }
252
253 //*****************************************************************************
255 //*****************************************************************************
256 template <typename TIterator>
257 ETL_CONSTEXPR bool operator!=(const etl::fixed_iterator<TIterator>& lhs, TIterator rhs)
258 {
259 return !(lhs == rhs);
260 }
261
262 //*****************************************************************************
264 //*****************************************************************************
265 template <typename TIterator>
266 ETL_CONSTEXPR bool operator!=(TIterator lhs, const etl::fixed_iterator<TIterator>& rhs)
267 {
268 return !(lhs == rhs);
269 }
270} // namespace etl
271
272#endif
ETL_CONSTEXPR etl::iterator_traits< TIterator >::reference operator*() const
Dereference operator.
Definition fixed_iterator.h:119
ETL_CONSTEXPR14 fixed_iterator & operator-=(typename etl::iterator_traits< TIterator >::difference_type)
-= operator.
Definition fixed_iterator.h:159
ETL_CONSTEXPR14 fixed_iterator operator--(int)
Decrement (Does nothing).
Definition fixed_iterator.h:103
ETL_CONSTEXPR14 fixed_iterator & operator=(TIterator new_it)
Assignment from iterator.
Definition fixed_iterator.h:167
ETL_CONSTEXPR const TIterator operator->() const
-> operator.
Definition fixed_iterator.h:135
ETL_CONSTEXPR14 fixed_iterator & operator+=(typename etl::iterator_traits< TIterator >::difference_type)
+= operator.
Definition fixed_iterator.h:151
ETL_CONSTEXPR fixed_iterator(const fixed_iterator &other)
Copy constructor.
Definition fixed_iterator.h:71
ETL_CONSTEXPR fixed_iterator()
Default constructor.
Definition fixed_iterator.h:55
ETL_CONSTEXPR14 fixed_iterator & operator--()
Decrement (Does nothing).
Definition fixed_iterator.h:95
ETL_CONSTEXPR14 fixed_iterator & operator++()
Increment (Does nothing).
Definition fixed_iterator.h:79
ETL_CONSTEXPR14 fixed_iterator & operator=(fixed_iterator other)
Assignment from fixed_iterator.
Definition fixed_iterator.h:176
ETL_CONSTEXPR fixed_iterator(TIterator it_)
Construct from iterator.
Definition fixed_iterator.h:63
ETL_CONSTEXPR14 etl::iterator_traits< TIterator >::reference operator*()
Dereference operator.
Definition fixed_iterator.h:111
ETL_CONSTEXPR14 TIterator operator->()
-> operator.
Definition fixed_iterator.h:127
ETL_CONSTEXPR14 fixed_iterator operator++(int)
Increment (Does nothing).
Definition fixed_iterator.h:87
Definition fixed_iterator.h:49
Definition absolute.h:40
ETL_CONSTEXPR14 bool operator==(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1078
ETL_CONSTEXPR14 etl::circular_iterator< TIterator > operator-(etl::circular_iterator< TIterator > &lhs, typename etl::iterator_traits< TIterator >::difference_type offset)
Definition circular_iterator.h:675
ETL_CONSTEXPR14 bool operator!=(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1090
ETL_CONSTEXPR14 etl::circular_iterator< TIterator > operator+(etl::circular_iterator< TIterator > &lhs, typename etl::iterator_traits< TIterator >::difference_type offset)
Definition circular_iterator.h:662
iterator
Definition iterator.h:482