Skip to content

Commit 0a31272

Browse files
Fix Wdeprecated-copy implicitly declared ... is deprecated (#4)
1 parent 9662806 commit 0a31272

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

include/bitlib/bit-iterator/bit_iterator.hpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,14 +270,28 @@ constexpr bit_iterator<Iterator> bit_iterator<Iterator>::operator-(difference_ty
270270
// Increments the iterator by several bits and returns it
271271
template <class Iterator>
272272
constexpr bit_iterator<Iterator>& bit_iterator<Iterator>::operator+=(difference_type n) {
273-
*this = *this + n;
273+
constexpr difference_type digits = binary_digits<word_type>::value;
274+
const difference_type sum = _position + n;
275+
difference_type diff = sum / digits;
276+
if (sum < 0 && diff * digits != sum) {
277+
--diff;
278+
}
279+
_current = std::next(_current, diff);
280+
_position = (sum - diff * digits);
274281
return *this;
275282
}
276283

277284
// Decrements the iterator by several bits and returns it
278285
template <class Iterator>
279286
constexpr bit_iterator<Iterator>& bit_iterator<Iterator>::operator-=(difference_type n) {
280-
*this = *this - n;
287+
constexpr difference_type digits = binary_digits<word_type>::value;
288+
const difference_type sum = _position - n;
289+
difference_type diff = sum / digits;
290+
if (sum < 0 && diff * digits != sum) {
291+
--diff;
292+
}
293+
_current = std::next(_current, diff);
294+
_position = (sum - diff * digits);
281295
return *this;
282296
}
283297
// -------------------------------------------------------------------------- //

0 commit comments

Comments
 (0)