diff --git a/include/nlohmann/detail/json_metadata.hpp b/include/nlohmann/detail/json_metadata.hpp index 314eb673e..7d220a754 100644 --- a/include/nlohmann/detail/json_metadata.hpp +++ b/include/nlohmann/detail/json_metadata.hpp @@ -18,7 +18,7 @@ class json_metadata return m_metadata; } private: - metadata_t m_metadata; + metadata_t m_metadata = {}; }; template<> diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp index d892580f9..fdabf259f 100644 --- a/include/nlohmann/json.hpp +++ b/include/nlohmann/json.hpp @@ -2333,11 +2333,10 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec // check that passed value is valid other.assert_invariant(); - json_metadata_t::operator=(std::move(other)); - using std::swap; swap(m_type, other.m_type); swap(m_value, other.m_value); + json_metadata_t::operator=(std::move(other)); set_parents(); assert_invariant(); diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index a37dc2504..c4e2c8e9d 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -12377,7 +12377,7 @@ class json_metadata return m_metadata; } private: - metadata_t m_metadata; + metadata_t m_metadata = {}; }; template<> @@ -17649,7 +17649,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec detail::parser_callback_tcb = nullptr, const bool allow_exceptions = true, const bool ignore_comments = false - ) + ) { return ::nlohmann::detail::parser(std::move(adapter), std::move(cb), allow_exceptions, ignore_comments); @@ -19772,11 +19772,10 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec // check that passed value is valid other.assert_invariant(); - json_metadata_t::operator=(std::move(other)); - using std::swap; swap(m_type, other.m_type); swap(m_value, other.m_value); + json_metadata_t::operator=(std::move(other)); set_parents(); assert_invariant();