From f1db2f0ca3915384b30ea5a098af2d48b016bb97 Mon Sep 17 00:00:00 2001 From: hurchalla Date: Wed, 12 Jun 2024 18:07:19 -0700 Subject: [PATCH] add move assignment operator to ImplBitPackedUintVector, and declare copy assignment deleted --- .../util/detail/ImplBitpackedUintVector.h | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/include/hurchalla/util/detail/ImplBitpackedUintVector.h b/include/hurchalla/util/detail/ImplBitpackedUintVector.h index e403823..2783b42 100644 --- a/include/hurchalla/util/detail/ImplBitpackedUintVector.h +++ b/include/hurchalla/util/detail/ImplBitpackedUintVector.h @@ -77,13 +77,22 @@ struct ImplBitpackedUintVector public: ImplBitpackedUintVector(const ImplBitpackedUintVector&) = delete; - ImplBitpackedUintVector(ImplBitpackedUintVector&& other) : + ImplBitpackedUintVector(ImplBitpackedUintVector&& other) noexcept : packed_count(other.packed_count), vec8_bytes(other.vec8_bytes), upvec(std::move(other.upvec)), vec8(reinterpret_cast(upvec.get())) {} + ImplBitpackedUintVector& operator=(const ImplBitpackedUintVector&) = delete; + ImplBitpackedUintVector& operator=(ImplBitpackedUintVector&& other) noexcept + { + packed_count = other.packed_count; + vec8_bytes = other.vec8_bytes; + upvec = std::move(other.upvec); + vec8 = reinterpret_cast(upvec.get()); + } + ImplBitpackedUintVector(size_type count) : packed_count(count), vec8_bytes(getBytesFromCount(count)), @@ -238,7 +247,7 @@ struct ImplBitpackedUintVector overflowed = true; starting_byte = static_cast(sum); - using P = safely_promote_unsigned::type; + using P = typename safely_promote_unsigned::type; // Below: (index*ELEM_BITLEN) might overflow, but since we use the // product mod 8, that's ok so long as we use unsigned arithmetic. bit_offset = static_cast( @@ -421,7 +430,7 @@ struct ImplBitpackedUintVector static_assert(elements_per_byte != 0, ""); starting_byte = static_cast(index / elements_per_byte); - using P = safely_promote_unsigned::type; + using P = typename safely_promote_unsigned::type; // Note: (index*element_bitlen) might overflow, but that's ok so long // as we use unsigned arithmetic, since we use the product mod 8. bit_offset = static_cast( @@ -610,7 +619,7 @@ struct ImplBitpackedUintVector HPBC_ASSERT2(index <= ST_MAX - index / spills_per_byte); // Thus we know the sum in starting_byte couldn't have overflowed. - using P = safely_promote_unsigned::type; + using P = typename safely_promote_unsigned::type; // Below: (index*element_bitlen) might overflow, but since we use the // product mod 8, that's ok so long as we use unsigned arithmetic. bit_offset = static_cast(