Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Clang-Tidy warnings #4047

Merged
merged 8 commits into from
Jun 8, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
💚 fix Clang-Tidy warnings
  • Loading branch information
nlohmann committed Jun 6, 2023
commit 682998faf63bd95a431fe8cc64c6947cfc0425ad
4 changes: 2 additions & 2 deletions include/nlohmann/detail/iterators/iteration_proxy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ template<typename IteratorType> 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<IteratorType>::value
&& std::is_nothrow_move_constructible<string_type>::value) = default;
&& std::is_nothrow_move_constructible<string_type>::value) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor)
iteration_proxy_value& operator=(iteration_proxy_value&&)
noexcept(std::is_nothrow_move_assignable<IteratorType>::value
&& std::is_nothrow_move_assignable<string_type>::value) = default;
&& std::is_nothrow_move_assignable<string_type>::value) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor)
~iteration_proxy_value() = default;

/// dereference operator (needed for range-based for)
Expand Down
10 changes: 5 additions & 5 deletions include/nlohmann/ordered_map.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
{
for (auto it = this->begin(); it != this->end(); ++it)
{
if (m_compare(it->first, key))
if (m_compare(it->first, std::forward<KeyType>(key)))
nlohmann marked this conversation as resolved.
Show resolved Hide resolved
{
return it->second;
}
Expand Down Expand Up @@ -150,7 +150,7 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
{
for (auto it = this->begin(); it != this->end(); ++it)
{
if (m_compare(it->first, key))
if (m_compare(it->first, std::forward<KeyType>(key)))
{
return it->second;
}
Expand Down Expand Up @@ -184,7 +184,7 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
{
for (auto it = this->begin(); it != this->end(); ++it)
{
if (m_compare(it->first, key))
if (m_compare(it->first, std::forward<KeyType>(key)))
{
// Since we cannot move const Keys, re-construct them in place
for (auto next = it; ++next != this->end(); ++it)
Expand Down Expand Up @@ -275,7 +275,7 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
{
for (auto it = this->begin(); it != this->end(); ++it)
{
if (m_compare(it->first, key))
if (m_compare(it->first, std::forward<KeyType>(key)))
{
return 1;
}
Expand All @@ -301,7 +301,7 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
{
for (auto it = this->begin(); it != this->end(); ++it)
{
if (m_compare(it->first, key))
if (m_compare(it->first, std::forward<KeyType>(key)))
{
return it;
}
Expand Down
14 changes: 7 additions & 7 deletions single_include/nlohmann/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5151,10 +5151,10 @@ template<typename IteratorType> 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<IteratorType>::value
&& std::is_nothrow_move_constructible<string_type>::value) = default;
&& std::is_nothrow_move_constructible<string_type>::value) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor)
iteration_proxy_value& operator=(iteration_proxy_value&&)
noexcept(std::is_nothrow_move_assignable<IteratorType>::value
&& std::is_nothrow_move_assignable<string_type>::value) = default;
&& std::is_nothrow_move_assignable<string_type>::value) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor)
~iteration_proxy_value() = default;

/// dereference operator (needed for range-based for)
Expand Down Expand Up @@ -19040,7 +19040,7 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
{
for (auto it = this->begin(); it != this->end(); ++it)
{
if (m_compare(it->first, key))
if (m_compare(it->first, std::forward<KeyType>(key)))
{
return it->second;
}
Expand Down Expand Up @@ -19068,7 +19068,7 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
{
for (auto it = this->begin(); it != this->end(); ++it)
{
if (m_compare(it->first, key))
if (m_compare(it->first, std::forward<KeyType>(key)))
{
return it->second;
}
Expand Down Expand Up @@ -19102,7 +19102,7 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
{
for (auto it = this->begin(); it != this->end(); ++it)
{
if (m_compare(it->first, key))
if (m_compare(it->first, std::forward<KeyType>(key)))
{
// Since we cannot move const Keys, re-construct them in place
for (auto next = it; ++next != this->end(); ++it)
Expand Down Expand Up @@ -19193,7 +19193,7 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
{
for (auto it = this->begin(); it != this->end(); ++it)
{
if (m_compare(it->first, key))
if (m_compare(it->first, std::forward<KeyType>(key)))
{
return 1;
}
Expand All @@ -19219,7 +19219,7 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
{
for (auto it = this->begin(); it != this->end(); ++it)
{
if (m_compare(it->first, key))
if (m_compare(it->first, std::forward<KeyType>(key)))
{
return it;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/src/unit-allocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ struct bad_allocator : std::allocator<T>
template<class U> bad_allocator(const bad_allocator<U>& /*unused*/) { }

template<class... Args>
void construct(T* /*unused*/, Args&& ... /*unused*/)
void construct(T* /*unused*/, Args&& ... /*unused*/) // NOLINT(cppcoreguidelines-missing-std-forward)
{
throw std::bad_alloc();
}
Expand Down