From 84367553d7020e7001eced60cf84e433c8a3eba2 Mon Sep 17 00:00:00 2001 From: Peter McLean Date: Mon, 5 May 2025 13:54:15 -0400 Subject: [PATCH] Fix Wdeprecated-copy implicitly declared ... is deprecated --- include/bitlib/bit-iterator/bit_iterator.hpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/include/bitlib/bit-iterator/bit_iterator.hpp b/include/bitlib/bit-iterator/bit_iterator.hpp index 953b60a9..90b4828a 100644 --- a/include/bitlib/bit-iterator/bit_iterator.hpp +++ b/include/bitlib/bit-iterator/bit_iterator.hpp @@ -270,14 +270,28 @@ constexpr bit_iterator bit_iterator::operator-(difference_ty // Increments the iterator by several bits and returns it template constexpr bit_iterator& bit_iterator::operator+=(difference_type n) { - *this = *this + n; + constexpr difference_type digits = binary_digits::value; + const difference_type sum = _position + n; + difference_type diff = sum / digits; + if (sum < 0 && diff * digits != sum) { + --diff; + } + _current = std::next(_current, diff); + _position = (sum - diff * digits); return *this; } // Decrements the iterator by several bits and returns it template constexpr bit_iterator& bit_iterator::operator-=(difference_type n) { - *this = *this - n; + constexpr difference_type digits = binary_digits::value; + const difference_type sum = _position - n; + difference_type diff = sum / digits; + if (sum < 0 && diff * digits != sum) { + --diff; + } + _current = std::next(_current, diff); + _position = (sum - diff * digits); return *this; } // -------------------------------------------------------------------------- //