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 //***************************************************************************
56 : it(TIterator())
57 {
58 }
59
60 //***************************************************************************
62 //***************************************************************************
63 fixed_iterator(TIterator it_)
64 : it(it_)
65 {
66 }
67
68 //***************************************************************************
70 //***************************************************************************
72 : it(other.it)
73 {
74 }
75
76 //***************************************************************************
78 //***************************************************************************
80 {
81 return *this;
82 }
83
84 //***************************************************************************
86 //***************************************************************************
88 {
89 return *this;
90 }
91
92 //***************************************************************************
94 //***************************************************************************
96 {
97 return *this;
98 }
99
100 //***************************************************************************
102 //***************************************************************************
104 {
105 return *this;
106 }
107
108 //***************************************************************************
110 //***************************************************************************
111 typename etl::iterator_traits<TIterator>::value_type operator*()
112 {
113 return *it;
114 }
115
116 //***************************************************************************
118 //***************************************************************************
119 const typename etl::iterator_traits<TIterator>::value_type operator*() const
120 {
121 return *it;
122 }
123
124 //***************************************************************************
126 //***************************************************************************
127 TIterator operator->()
128 {
129 return it;
130 }
131
132 //***************************************************************************
134 //***************************************************************************
135 const TIterator operator->() const
136 {
137 return it;
138 }
139
140 //***************************************************************************
142 //***************************************************************************
143 operator TIterator() const
144 {
145 return it;
146 }
147
148 //***************************************************************************
150 //***************************************************************************
151 fixed_iterator& operator+=(typename etl::iterator_traits<TIterator>::difference_type /*offset*/)
152 {
153 return *this;
154 }
155
156 //***************************************************************************
158 //***************************************************************************
159 fixed_iterator& operator-=(typename etl::iterator_traits<TIterator>::difference_type /*offset*/)
160 {
161 return *this;
162 }
163
164 //***************************************************************************
166 //***************************************************************************
167 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>
191 etl::fixed_iterator<TIterator>& operator+(etl::fixed_iterator<TIterator>& lhs, typename etl::iterator_traits<TIterator>::difference_type /*rhs*/)
192 {
193 return lhs;
194 }
195
196 //*****************************************************************************
198 //*****************************************************************************
199 template <typename TIterator>
200 etl::fixed_iterator<TIterator>& operator-(etl::fixed_iterator<TIterator>& lhs, typename etl::iterator_traits<TIterator>::difference_type /*rhs*/)
201 {
202 return lhs;
203 }
204
205 //*****************************************************************************
207 //*****************************************************************************
208 template <typename TIterator>
209 typename etl::iterator_traits<TIterator>::difference_type operator-(const etl::fixed_iterator<TIterator>& lhs,
211 {
212 return TIterator(lhs) - TIterator(rhs);
213 }
214
215 //*****************************************************************************
217 //*****************************************************************************
218 template <typename TIterator>
220 {
221 return TIterator(lhs) == TIterator(rhs);
222 }
223
224 //*****************************************************************************
226 //*****************************************************************************
227 template <typename TIterator>
228 bool operator==(const etl::fixed_iterator<TIterator>& lhs, TIterator rhs)
229 {
230 return TIterator(lhs) == rhs;
231 }
232
233 //*****************************************************************************
235 //*****************************************************************************
236 template <typename TIterator>
237 bool operator==(TIterator lhs, const etl::fixed_iterator<TIterator>& rhs)
238 {
239 return lhs == TIterator(rhs);
240 }
241
242 //*****************************************************************************
244 //*****************************************************************************
245 template <typename TIterator>
247 {
248 return !(lhs == rhs);
249 }
250
251 //*****************************************************************************
253 //*****************************************************************************
254 template <typename TIterator>
255 bool operator!=(const etl::fixed_iterator<TIterator>& lhs, TIterator rhs)
256 {
257 return !(lhs == rhs);
258 }
259
260 //*****************************************************************************
262 //*****************************************************************************
263 template <typename TIterator>
264 bool operator!=(TIterator& lhs, const etl::fixed_iterator<TIterator>& rhs)
265 {
266 return !(lhs == rhs);
267 }
268} // namespace etl
269
270#endif
fixed_iterator()
Default constructor.
Definition fixed_iterator.h:55
TIterator operator->()
-> operator.
Definition fixed_iterator.h:127
fixed_iterator & operator++()
Increment (Does nothing).
Definition fixed_iterator.h:79
etl::iterator_traits< TIterator >::value_type operator*()
Dereference operator.
Definition fixed_iterator.h:111
fixed_iterator & operator=(TIterator new_it)
Assignment from iterator.
Definition fixed_iterator.h:167
fixed_iterator operator--(int)
Decrement (Does nothing).
Definition fixed_iterator.h:103
fixed_iterator & operator+=(typename etl::iterator_traits< TIterator >::difference_type)
+= operator.
Definition fixed_iterator.h:151
const TIterator operator->() const
-> operator.
Definition fixed_iterator.h:135
fixed_iterator & operator--()
Decrement (Does nothing).
Definition fixed_iterator.h:95
fixed_iterator & operator=(fixed_iterator other)
Assignment from fixed_iterator.
Definition fixed_iterator.h:176
const etl::iterator_traits< TIterator >::value_type operator*() const
Dereference operator.
Definition fixed_iterator.h:119
fixed_iterator(TIterator it_)
Construct from iterator.
Definition fixed_iterator.h:63
fixed_iterator operator++(int)
Increment (Does nothing).
Definition fixed_iterator.h:87
fixed_iterator(const fixed_iterator &other)
Copy constructor.
Definition fixed_iterator.h:71
fixed_iterator & operator-=(typename etl::iterator_traits< TIterator >::difference_type)
-= operator.
Definition fixed_iterator.h:159
Definition fixed_iterator.h:49
bitset_ext
Definition absolute.h:40
ETL_CONSTEXPR14 bool operator==(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1081
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:1093
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:424