Erase the source SeArray immediately in move assignment operator.
This commit is contained in:
1 parent
dcaeab7b43
commit
5ba326aa5a
2 files changed
+23
-1
No files matched your search
@@ -27,7 +27,20 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
SeArray & operator=(const SeArray & other) = default;
|
SeArray & operator=(const SeArray & other) = default;
|
||||||
SeArray & operator=(SeArray && other) = default;
|
|
||||||
|
SeArray & operator=(SeArray && other)
|
||||||
|
{
|
||||||
|
if (this == &other)
|
||||||
|
{
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
EraseImpl();
|
||||||
|
Storage_ = std::move(other.Storage_);
|
||||||
|
other.EraseImpl();
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
~SeArray()
|
~SeArray()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -305,6 +305,9 @@ TEST(SeArrayTests, MoveAssignTest)
|
|||||||
|
|
||||||
ASSERT_EQ(0xaa, arr1[0]);
|
ASSERT_EQ(0xaa, arr1[0]);
|
||||||
ASSERT_EQ(0xbb, arr1[1]);
|
ASSERT_EQ(0xbb, arr1[1]);
|
||||||
|
|
||||||
|
ASSERT_EQ(0, arr2[0]);
|
||||||
|
ASSERT_EQ(0, arr2[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -324,6 +327,12 @@ TEST(SeArrayTests, MoveAssignTest)
|
|||||||
ASSERT_EQ(0, arr1[2]);
|
ASSERT_EQ(0, arr1[2]);
|
||||||
ASSERT_EQ(0, arr1[3]);
|
ASSERT_EQ(0, arr1[3]);
|
||||||
ASSERT_EQ(0, arr1[4]);
|
ASSERT_EQ(0, arr1[4]);
|
||||||
|
|
||||||
|
ASSERT_EQ(0, arr2[0]);
|
||||||
|
ASSERT_EQ(0, arr2[1]);
|
||||||
|
ASSERT_EQ(0, arr2[2]);
|
||||||
|
ASSERT_EQ(0, arr2[3]);
|
||||||
|
ASSERT_EQ(0, arr2[4]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user