Erase the source SeArray immediately in move ctor.

This commit is contained in:
hashlag committed 2026-10-18 01:00:52 +03:00
1 parent 49a4b18163
commit dcaeab7b43
2 files changed
+10 -1

No files matched your search

+7 -1
View File
@@ -4,6 +4,7 @@
#include <array> #include <array>
#include <concepts> #include <concepts>
#include <cstddef> #include <cstddef>
#include <utility>
namespace Chaos::Service namespace Chaos::Service
{ {
@@ -18,7 +19,12 @@ public:
} }
SeArray(const SeArray & other) = delete; SeArray(const SeArray & other) = delete;
SeArray(SeArray && other) = default;
SeArray(SeArray && other)
{
Storage_ = std::move(other.Storage_);
other.EraseImpl();
}
SeArray & operator=(const SeArray & other) = default; SeArray & operator=(const SeArray & other) = default;
SeArray & operator=(SeArray && other) = default; SeArray & operator=(SeArray && other) = default;
+3
View File
@@ -337,5 +337,8 @@ TEST(SeArrayTests, MoveConstructTest)
SeArray<int32_t, 2> arr2(std::move(arr1)); SeArray<int32_t, 2> arr2(std::move(arr1));
ASSERT_EQ(0x11, arr2[0]); ASSERT_EQ(0x11, arr2[0]);
ASSERT_EQ(0x22, arr2[1]); ASSERT_EQ(0x22, arr2[1]);
ASSERT_EQ(0, arr1[0]);
ASSERT_EQ(0, arr1[1]);
} }
} }