47 friend class ConstBitIterator;
51 checkBitLocationPositive(offset);
53 BitIterator(
const BitIterator& iter) =
default;
55 bool operator!()
const
57 return !(*m_flag)[m_bit_ref];
59 constexpr operator bool()
const
61 return (*m_flag)[m_bit_ref];
71 bool byteAligned()
const
73 return m_bit_ref == 0;
85 return *(m_flag + offset);
87 BitIterator& operator++()
100 BitIterator& operator--()
113 BitIterator operator++(
int)
115 BitIterator old_value(*
this);
127 BitIterator operator--(
int)
129 BitIterator old_value(*
this);
141 template<
class t_type>
142 BitIterator& operator+=(
const t_type& movement)
147 template<
class t_type>
148 BitIterator& operator-=(
const t_type& movement)
154 bool operator>=(
const bool*)
const {
return false; };
155 bool operator<=(
const bool*)
const {
return true; };
156 bool operator<(
const bool*)
const {
return true; };
157 bool operator>(
const bool*)
const {
return false; };
159 bool operator>(
const BitIterator& other)
const
161 if (m_flag == other.m_flag)
162 return m_bit_ref > other.m_bit_ref;
164 return m_flag > other.m_flag;
166 bool operator<(
const BitIterator& other)
const
168 if (m_flag == other.m_flag)
169 return m_bit_ref < other.m_bit_ref;
171 return m_flag < other.m_flag;
173 ptrdiff_t operator-(
const BitIterator& rhs)
175 ptrdiff_t byte_diff = this->m_flag - rhs.m_flag;
176 ptrdiff_t bit_diff = this->m_bit_ref - rhs.m_bit_ref;
177 return byte_diff * 8 + bit_diff;
179 template<
class t_type>
180 BitIterator operator+(t_type distance)
const
182 BitIterator sum = *
this;
186 template<
class t_type>
187 BitIterator operator-(t_type distance)
const
189 BitIterator sum = *
this;
194 BitIterator& operator=(
const BitIterator& rawIterator) =
default;
196 bool operator==(
const BitIterator& rawIterator)
const {
return (m_bit_ref == rawIterator.m_bit_ref && m_flag == rawIterator.m_flag); }
197 bool operator!=(
const BitIterator& rawIterator)
const {
return (m_bit_ref != rawIterator.m_bit_ref || m_flag != rawIterator.m_flag); }
200 void checkBitLocationPositive(
sint04 bit)
const
209 void checkBitLocationNegative(
sint04 bit)
const
220 mutable uint01 m_bit_ref = Constant<uint01>::Invalid;
226 class ConstBitIterator
229 friend class BitIterator;
230 ConstBitIterator(
const BitIterator& iter)
231 : m_flag(iter.m_flag)
232 , m_bit_ref(iter.m_bit_ref)
237 checkBitLocationPositive(offset);
244 ConstBitIterator(
const ConstBitIterator& iter) =
default;
248 return (*m_flag)[m_bit_ref];
250 bool operator*()
const
252 return (*m_flag)[m_bit_ref];
254 bool operator==(
bool ref)
const
256 return (*m_flag)[m_bit_ref] == ref;
258 bool operator!()
const
260 return !(*m_flag)[m_bit_ref];
262 constexpr operator bool()
const
264 return (*m_flag)[m_bit_ref];
266 bool operator>(
const BitIterator& other)
const
268 if (m_flag == other.m_flag)
269 return m_bit_ref > other.m_bit_ref;
271 return m_flag > other.m_flag;
273 bool operator<(
const BitIterator& other)
const
275 if (m_flag == other.m_flag)
276 return m_bit_ref < other.m_bit_ref;
278 return m_flag < other.m_flag;
280 bool operator>(
const ConstBitIterator& other)
const
282 if (m_flag == other.m_flag)
283 return m_bit_ref > other.m_bit_ref;
285 return m_flag > other.m_flag;
287 bool operator<(
const ConstBitIterator& other)
const
289 if (m_flag == other.m_flag)
290 return m_bit_ref < other.m_bit_ref;
292 return m_flag < other.m_flag;
294 bool byteAligned()
const
296 return m_bit_ref == 0;
302 const BitFlag& byteFlag()
const
308 return *(m_flag + offset);
310 ConstBitIterator& operator++()
323 ConstBitIterator& operator--()
336 ConstBitIterator operator++(
int)
338 ConstBitIterator old_value(*
this);
350 ConstBitIterator operator--(
int)
352 ConstBitIterator old_value(*
this);
364 template<
class t_type>
365 ConstBitIterator& operator+=(
const t_type& movement)
370 template<
class t_type>
371 ConstBitIterator& operator-=(
const t_type& movement)
377 ptrdiff_t operator-(
const ConstBitIterator& rhs)
379 ptrdiff_t byte_diff = this->m_flag - rhs.m_flag;
380 ptrdiff_t bit_diff = this->m_bit_ref - rhs.m_bit_ref;
381 return byte_diff * 8 + bit_diff;
385 ConstBitIterator& operator=(
const ConstBitIterator& rawIterator) =
default;
387 bool operator==(
const ConstBitIterator& rawIterator)
const {
return (m_bit_ref == rawIterator.m_bit_ref && m_flag == rawIterator.m_flag); }
388 bool operator!=(
const ConstBitIterator& rawIterator)
const {
return (m_bit_ref != rawIterator.m_bit_ref || m_flag != rawIterator.m_flag); }
389 bool operator==(
const BitIterator& rawIterator)
const {
return (m_bit_ref == rawIterator.m_bit_ref && m_flag == rawIterator.m_flag); }
390 bool operator!=(
const BitIterator& rawIterator)
const {
return (m_bit_ref != rawIterator.m_bit_ref || m_flag != rawIterator.m_flag); }
391 template<
class t_type>
392 ConstBitIterator operator+(
const t_type& movement)
394 ConstBitIterator sum(*
this);
398 template<
class t_type>
399 ConstBitIterator operator-(
const t_type& movement)
401 ConstBitIterator sum(*
this);
406 void checkBitLocationPositive(
sint04 bit)
const
415 void checkBitLocationNegative(
sint04 bit)
const
426 mutable uint01 m_bit_ref = Constant<uint01>::Invalid;