fixing memory leak fix

This commit is contained in:
2023-11-30 15:06:04 +01:00
parent 93cb88df26
commit 9114a6f252
+12 -4
View File
@@ -197,11 +197,15 @@ public:
} }
constexpr Map(const Map& other) constexpr Map(const Map& other)
: alloc(other.alloc) : alloc(other.alloc)
, root(other.root) , root(nullptr)
, iteratorsDirty(true) , iteratorsDirty(true)
, _size(other._size) , _size(0)
, comp(other.comp) , comp(other.comp)
{ {
for(const auto& [key, val] : other)
{
this->operator[](key) = val;
}
} }
constexpr Map(Map&& other) noexcept constexpr Map(Map&& other) noexcept
: alloc(std::move(other.alloc)) : alloc(std::move(other.alloc))
@@ -220,9 +224,13 @@ public:
if(this != &other) if(this != &other)
{ {
alloc = other.alloc; alloc = other.alloc;
root = other.root;
_size = other._size;
comp = other.comp; comp = other.comp;
root = nullptr;
_size = 0;
for(const auto& [key, val] : other)
{
this->operator[](key) = val;
}
markIteratorsDirty(); markIteratorsDirty();
} }
return *this; return *this;