From cc4d7f1697ad465889fa90284c66a7f5e42ed1fc Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Fri, 15 Mar 2024 18:33:24 +0100 Subject: [PATCH] :rotating_light: fix warning --- include/nlohmann/json.hpp | 6 ++---- single_include/nlohmann/json.hpp | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp index 31ca64539b..f4d582f504 100644 --- a/include/nlohmann/json.hpp +++ b/include/nlohmann/json.hpp @@ -1213,11 +1213,9 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec /// @sa https://json.nlohmann.me/api/basic_json/basic_json/ basic_json(basic_json&& other) noexcept : json_base_class_t(std::forward(other)), - m_data(std::move(other.m_data)) + // check that passed value is valid (has to be done before moving) + m_data(std::move((other.assert_invariant(false), other.m_data))) { - // check that passed value is valid - other.assert_invariant(false); - // invalidate payload other.m_data.m_type = value_t::null; other.m_data.m_value = {}; diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 82138b02f5..546ea18d29 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -20516,11 +20516,9 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec /// @sa https://json.nlohmann.me/api/basic_json/basic_json/ basic_json(basic_json&& other) noexcept : json_base_class_t(std::forward(other)), - m_data(std::move(other.m_data)) + // check that passed value is valid (has to be done before moving) + m_data(std::move((other.assert_invariant(false), other.m_data))) { - // check that passed value is valid - other.assert_invariant(false); - // invalidate payload other.m_data.m_type = value_t::null; other.m_data.m_value = {};