diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/chilbert/DynamicBitVec.hpp | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/include/chilbert/DynamicBitVec.hpp b/include/chilbert/DynamicBitVec.hpp index 2bed27f..fe7a535 100644 --- a/include/chilbert/DynamicBitVec.hpp +++ b/include/chilbert/DynamicBitVec.hpp @@ -79,16 +79,18 @@ public: DynamicBitVec& operator=(const DynamicBitVec& vec) { - if (num_racks() < vec.num_racks()) { - m_racks = make_racks(vec.num_racks()); - m_size = vec.m_size; - memcpy(data(), vec.data(), data_size()); - } else if (vec.num_racks() > 0) { - m_size = vec.m_size; - memcpy(data(), vec.data(), data_size()); - } else { - m_size = 0; - m_racks.reset(); + if (&vec != this) { + if (num_racks() < vec.num_racks()) { + m_racks = make_racks(vec.num_racks()); + m_size = vec.m_size; + memcpy(data(), vec.data(), data_size()); + } else if (vec.num_racks() > 0) { + m_size = vec.m_size; + memcpy(data(), vec.data(), data_size()); + } else { + m_size = 0; + m_racks.reset(); + } } return *this; |