From b7dd00a69f271ca95fde5be170da159166f611b8 Mon Sep 17 00:00:00 2001 From: Dominik Drexler Date: Sun, 17 Mar 2024 14:27:28 +0100 Subject: [PATCH] added difference on bitset --- include/flatmemory/details/types/bitset.hpp | 24 +++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/include/flatmemory/details/types/bitset.hpp b/include/flatmemory/details/types/bitset.hpp index d48e6a7..7e70ebb 100644 --- a/include/flatmemory/details/types/bitset.hpp +++ b/include/flatmemory/details/types/bitset.hpp @@ -979,6 +979,30 @@ class Builder> : public IBuilder>> return *this; } + template + Builder& operator-=(const Other& other) + { + // Fetch data + const auto& other_blocks = other.get_blocks(); + bool other_default_bit_value = other.get_default_bit_value(); + + // Update default bit value + m_default_bit_value &= !other_default_bit_value; + + // Update blocks + resize_to_fit(other); + auto it = m_blocks.begin(); + auto other_it = other_blocks.begin(); + while (it != m_blocks.end()) + { + *it &= ~(*other_it); + ++it; + ++other_it; + } + + return *this; + } + /** * Lookup */