From 33775f59ff1a34cb4c67066e4b2f9afd8d8e0d47 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Fri, 4 Jun 2021 23:37:47 -0500 Subject: [PATCH] [ox/std] Fix Vector copy constructor not to move items --- deps/ox/src/ox/model/desctypes.hpp | 13 +++++++++---- deps/ox/src/ox/std/vector.hpp | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/deps/ox/src/ox/model/desctypes.hpp b/deps/ox/src/ox/model/desctypes.hpp index 3d988cc4..2ab8c25c 100644 --- a/deps/ox/src/ox/model/desctypes.hpp +++ b/deps/ox/src/ox/model/desctypes.hpp @@ -82,19 +82,24 @@ struct DescriptorField { ~DescriptorField(); - const DescriptorField &operator=(DescriptorField &&other) noexcept { + const DescriptorField &operator=(const DescriptorField &other) noexcept { type = other.type; fieldName = other.fieldName; subscriptLevels = other.subscriptLevels; typeName = other.typeName; ownsType = other.ownsType; + return *this; + } + const DescriptorField &operator=(DescriptorField &&other) noexcept { + type = move(other.type); other.type = {}; - other.fieldName = ""; + fieldName = move(other.fieldName); + subscriptLevels = move(other.subscriptLevels); other.subscriptLevels = {}; - other.typeName = ""; + typeName = move(other.typeName); + ownsType = move(other.ownsType); other.ownsType = {}; - return *this; } diff --git a/deps/ox/src/ox/std/vector.hpp b/deps/ox/src/ox/std/vector.hpp index f093d0a3..8190e065 100644 --- a/deps/ox/src/ox/std/vector.hpp +++ b/deps/ox/src/ox/std/vector.hpp @@ -301,7 +301,7 @@ Vector::Vector(const Vector &other) { m_cap = other.m_cap; this->initItems(&m_items, other.m_cap); for (std::size_t i = 0; i < m_size; ++i) { - m_items[i] = move(other.m_items[i]); + m_items[i] = other.m_items[i]; } }