From a36fb8575027887d813a12cf6314a54a56b261db Mon Sep 17 00:00:00 2001 From: Raphael Grimm Date: Sat, 25 Sep 2021 12:38:42 +0200 Subject: [PATCH] Fix issues reported by clang-tidy and more aggressive gcc flags for ci jobs --- include/nlohmann/detail/json_metadata.hpp | 2 +- include/nlohmann/json.hpp | 3 +-- single_include/nlohmann/json.hpp | 7 +++---- 3 files changed, 5 insertions(+), 7 deletions(-) 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();