diff --git a/include/jsoncons/basic_json.hpp b/include/jsoncons/basic_json.hpp index 054711fce..e7c63d80a 100644 --- a/include/jsoncons/basic_json.hpp +++ b/include/jsoncons/basic_json.hpp @@ -2168,16 +2168,20 @@ namespace jsoncons { switch (other.storage_kind()) { case json_storage_kind::long_str: - construct(std::move(other.cast())); + construct(other.cast()); + other.construct(); break; case json_storage_kind::byte_str: - construct(std::move(other.cast())); + construct(other.cast()); + other.construct(); break; case json_storage_kind::array: - construct(std::move(other.cast())); + construct(other.cast()); + other.construct(); break; case json_storage_kind::object: - construct(std::move(other.cast())); + construct(other.cast()); + other.construct(); break; default: JSONCONS_UNREACHABLE(); @@ -2201,24 +2205,7 @@ namespace jsoncons { } else { - switch (other.storage_kind()) - { - case json_storage_kind::long_str: - construct(std::move(other.cast()), alloc); - break; - case json_storage_kind::byte_str: - construct(std::move(other.cast()), alloc); - break; - case json_storage_kind::array: - construct(std::move(other.cast()), alloc); - break; - case json_storage_kind::object: - construct(std::move(other.cast()), alloc); - break; - default: - JSONCONS_UNREACHABLE(); - break; - } + uninitialized_copy_a(other, alloc); } }