Skip to content

Commit

Permalink
add move assignment operator to ImplBitPackedUintVector, and declare …
Browse files Browse the repository at this point in the history
…copy assignment deleted
  • Loading branch information
hurchalla committed Jun 13, 2024
1 parent 6f56425 commit f1db2f0
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions include/hurchalla/util/detail/ImplBitpackedUintVector.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<NoAliasUcharPtr>(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<NoAliasUcharPtr>(upvec.get());
}

ImplBitpackedUintVector(size_type count) :
packed_count(count),
vec8_bytes(getBytesFromCount(count)),
Expand Down Expand Up @@ -238,7 +247,7 @@ struct ImplBitpackedUintVector
overflowed = true;
starting_byte = static_cast<std::size_t>(sum);

using P = safely_promote_unsigned<size_type>::type;
using P = typename safely_promote_unsigned<size_type>::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<std::size_t>(
Expand Down Expand Up @@ -421,7 +430,7 @@ struct ImplBitpackedUintVector
static_assert(elements_per_byte != 0, "");

starting_byte = static_cast<std::size_t>(index / elements_per_byte);
using P = safely_promote_unsigned<size_type>::type;
using P = typename safely_promote_unsigned<size_type>::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<std::size_t>(
Expand Down Expand Up @@ -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<size_type>::type;
using P = typename safely_promote_unsigned<size_type>::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<std::size_t>(
Expand Down

0 comments on commit f1db2f0

Please # to comment.