From dcaeab7b4315f52638660646055ed31160146bbe Mon Sep 17 00:00:00 2001 From: hashlag Date: Sun, 18 Oct 2026 00:59:18 +0300 Subject: [PATCH] Erase the source SeArray immediately in move ctor. --- Chaos/Service/SeArray.hpp | 8 +++++++- ChaosTests/Service/SeArrayTests.cpp | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Chaos/Service/SeArray.hpp b/Chaos/Service/SeArray.hpp index 427dcf7..c8bf88e 100644 --- a/Chaos/Service/SeArray.hpp +++ b/Chaos/Service/SeArray.hpp @@ -4,6 +4,7 @@ #include #include #include +#include namespace Chaos::Service { @@ -18,7 +19,12 @@ public: } 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=(SeArray && other) = default; diff --git a/ChaosTests/Service/SeArrayTests.cpp b/ChaosTests/Service/SeArrayTests.cpp index 4a09120..3d6e33f 100644 --- a/ChaosTests/Service/SeArrayTests.cpp +++ b/ChaosTests/Service/SeArrayTests.cpp @@ -337,5 +337,8 @@ TEST(SeArrayTests, MoveConstructTest) SeArray arr2(std::move(arr1)); ASSERT_EQ(0x11, arr2[0]); ASSERT_EQ(0x22, arr2[1]); + + ASSERT_EQ(0, arr1[0]); + ASSERT_EQ(0, arr1[1]); } }