7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-03-30 04:56:54 +00:00

dynamic_bitset requires both sets to be same size

This commit is contained in:
Seth Hillbrand 2025-01-27 20:00:24 -08:00
parent f34f962455
commit 7ea6206126

View File

@ -186,21 +186,75 @@ public:
// Compound assignment AND operator
BASE_SET& operator&=(const BASE_SET& other)
{
sul::dynamic_bitset<uint64_t>::operator&=(other);
size_t my_size = size();
size_t other_size = other.size();
if( my_size == other_size )
{
sul::dynamic_bitset<uint64_t>::operator&=(other);
}
else if( my_size < other_size )
{
sul::dynamic_bitset<uint64_t>::resize( other_size );
sul::dynamic_bitset<uint64_t>::operator&=( other );
}
else
{
BASE_SET tmp( other );
tmp.resize( my_size );
sul::dynamic_bitset<uint64_t>::operator&=( tmp );
}
return *this;
}
// Compound assignment OR operator
BASE_SET& operator|=(const BASE_SET& other)
{
sul::dynamic_bitset<uint64_t>::operator|=(other);
size_t my_size = size();
size_t other_size = other.size();
if( my_size == other_size )
{
sul::dynamic_bitset<uint64_t>::operator|=(other);
}
else if( my_size < other_size )
{
sul::dynamic_bitset<uint64_t>::resize( other_size );
sul::dynamic_bitset<uint64_t>::operator|=( other );
}
else
{
BASE_SET tmp( other );
tmp.resize( my_size );
sul::dynamic_bitset<uint64_t>::operator|=( tmp );
}
return *this;
}
// Compound assignment XOR operator
BASE_SET& operator^=(const BASE_SET& other)
{
sul::dynamic_bitset<uint64_t>::operator^=(other);
size_t my_size = size();
size_t other_size = other.size();
if( my_size == other_size )
{
sul::dynamic_bitset<uint64_t>::operator^=(other);
}
else if( my_size < other_size )
{
sul::dynamic_bitset<uint64_t>::resize( other_size );
sul::dynamic_bitset<uint64_t>::operator^=( other );
}
else
{
BASE_SET tmp( other );
tmp.resize( my_size );
sul::dynamic_bitset<uint64_t>::operator^=( tmp );
}
return *this;
}