From 682998faf63bd95a431fe8cc64c6947cfc0425ad Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Tue, 6 Jun 2023 20:00:22 +0200 Subject: [PATCH] :green_heart: fix Clang-Tidy warnings --- .../nlohmann/detail/iterators/iteration_proxy.hpp | 4 ++-- include/nlohmann/ordered_map.hpp | 10 +++++----- single_include/nlohmann/json.hpp | 14 +++++++------- tests/src/unit-allocator.cpp | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/include/nlohmann/detail/iterators/iteration_proxy.hpp b/include/nlohmann/detail/iterators/iteration_proxy.hpp index 61b942000..33bfc36ba 100644 --- a/include/nlohmann/detail/iterators/iteration_proxy.hpp +++ b/include/nlohmann/detail/iterators/iteration_proxy.hpp @@ -69,10 +69,10 @@ template class iteration_proxy_value // older GCCs are a bit fussy and require explicit noexcept specifiers on defaulted functions iteration_proxy_value(iteration_proxy_value&&) noexcept(std::is_nothrow_move_constructible::value - && std::is_nothrow_move_constructible::value) = default; + && std::is_nothrow_move_constructible::value) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) iteration_proxy_value& operator=(iteration_proxy_value&&) noexcept(std::is_nothrow_move_assignable::value - && std::is_nothrow_move_assignable::value) = default; + && std::is_nothrow_move_assignable::value) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) ~iteration_proxy_value() = default; /// dereference operator (needed for range-based for) diff --git a/include/nlohmann/ordered_map.hpp b/include/nlohmann/ordered_map.hpp index 55c630d90..413ddb7ea 100644 --- a/include/nlohmann/ordered_map.hpp +++ b/include/nlohmann/ordered_map.hpp @@ -122,7 +122,7 @@ template , { for (auto it = this->begin(); it != this->end(); ++it) { - if (m_compare(it->first, key)) + if (m_compare(it->first, std::forward(key))) { return it->second; } @@ -150,7 +150,7 @@ template , { for (auto it = this->begin(); it != this->end(); ++it) { - if (m_compare(it->first, key)) + if (m_compare(it->first, std::forward(key))) { return it->second; } @@ -184,7 +184,7 @@ template , { for (auto it = this->begin(); it != this->end(); ++it) { - if (m_compare(it->first, key)) + if (m_compare(it->first, std::forward(key))) { // Since we cannot move const Keys, re-construct them in place for (auto next = it; ++next != this->end(); ++it) @@ -275,7 +275,7 @@ template , { for (auto it = this->begin(); it != this->end(); ++it) { - if (m_compare(it->first, key)) + if (m_compare(it->first, std::forward(key))) { return 1; } @@ -301,7 +301,7 @@ template , { for (auto it = this->begin(); it != this->end(); ++it) { - if (m_compare(it->first, key)) + if (m_compare(it->first, std::forward(key))) { return it; } diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 443a69fee..6ff98b01a 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -5151,10 +5151,10 @@ template class iteration_proxy_value // older GCCs are a bit fussy and require explicit noexcept specifiers on defaulted functions iteration_proxy_value(iteration_proxy_value&&) noexcept(std::is_nothrow_move_constructible::value - && std::is_nothrow_move_constructible::value) = default; + && std::is_nothrow_move_constructible::value) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) iteration_proxy_value& operator=(iteration_proxy_value&&) noexcept(std::is_nothrow_move_assignable::value - && std::is_nothrow_move_assignable::value) = default; + && std::is_nothrow_move_assignable::value) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) ~iteration_proxy_value() = default; /// dereference operator (needed for range-based for) @@ -19040,7 +19040,7 @@ template , { for (auto it = this->begin(); it != this->end(); ++it) { - if (m_compare(it->first, key)) + if (m_compare(it->first, std::forward(key))) { return it->second; } @@ -19068,7 +19068,7 @@ template , { for (auto it = this->begin(); it != this->end(); ++it) { - if (m_compare(it->first, key)) + if (m_compare(it->first, std::forward(key))) { return it->second; } @@ -19102,7 +19102,7 @@ template , { for (auto it = this->begin(); it != this->end(); ++it) { - if (m_compare(it->first, key)) + if (m_compare(it->first, std::forward(key))) { // Since we cannot move const Keys, re-construct them in place for (auto next = it; ++next != this->end(); ++it) @@ -19193,7 +19193,7 @@ template , { for (auto it = this->begin(); it != this->end(); ++it) { - if (m_compare(it->first, key)) + if (m_compare(it->first, std::forward(key))) { return 1; } @@ -19219,7 +19219,7 @@ template , { for (auto it = this->begin(); it != this->end(); ++it) { - if (m_compare(it->first, key)) + if (m_compare(it->first, std::forward(key))) { return it; } diff --git a/tests/src/unit-allocator.cpp b/tests/src/unit-allocator.cpp index f2e63552a..f9a25b24f 100644 --- a/tests/src/unit-allocator.cpp +++ b/tests/src/unit-allocator.cpp @@ -24,7 +24,7 @@ struct bad_allocator : std::allocator template bad_allocator(const bad_allocator& /*unused*/) { } template - void construct(T* /*unused*/, Args&& ... /*unused*/) + void construct(T* /*unused*/, Args&& ... /*unused*/) // NOLINT(cppcoreguidelines-missing-std-forward) { throw std::bad_alloc(); }