Skip to content

Commit

Permalink
🚨 suppress warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
nlohmann committed Aug 22, 2021
1 parent a78764d commit 200015c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion include/nlohmann/detail/meta/type_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ struct is_ordered_map
template <typename C> static one test( decltype(&C::capacity) ) ;
template <typename C> static two test(...);

enum { value = sizeof(test<T>(nullptr)) == sizeof(char) };
enum { value = sizeof(test<T>(nullptr)) == sizeof(char) }; // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
};

// to avoid useless casts (see https://github.com/nlohmann/json/issues/2893#issuecomment-889152324)
Expand Down
7 changes: 7 additions & 0 deletions include/nlohmann/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1338,11 +1338,18 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec

// ordered_json uses a vector internally, so pointers could have
// been invalidated; see https://github.com/nlohmann/json/issues/2962
#ifdef JSON_HEDLEY_MSVC_VERSION
#pragma warning(push )
#pragma warning(disable : 4127) // ignore warning to replace if with if constexpr
#endif
if (detail::is_ordered_map<object_t>::value)
{
set_parents();
return j;
}
#ifdef JSON_HEDLEY_MSVC_VERSION
#pragma warning( pop )
#endif

j.m_parent = this;
#else
Expand Down
9 changes: 8 additions & 1 deletion single_include/nlohmann/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3860,7 +3860,7 @@ struct is_ordered_map
template <typename C> static one test( decltype(&C::capacity) ) ;
template <typename C> static two test(...);

enum { value = sizeof(test<T>(nullptr)) == sizeof(char) };
enum { value = sizeof(test<T>(nullptr)) == sizeof(char) }; // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
};

// to avoid useless casts (see https://github.com/nlohmann/json/issues/2893#issuecomment-889152324)
Expand Down Expand Up @@ -18739,11 +18739,18 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec

// ordered_json uses a vector internally, so pointers could have
// been invalidated; see https://github.com/nlohmann/json/issues/2962
#ifdef JSON_HEDLEY_MSVC_VERSION
#pragma warning(push )
#pragma warning(disable : 4127) // ignore warning to replace if with if constexpr
#endif
if (detail::is_ordered_map<object_t>::value)
{
set_parents();
return j;
}
#ifdef JSON_HEDLEY_MSVC_VERSION
#pragma warning( pop )
#endif

j.m_parent = this;
#else
Expand Down
2 changes: 1 addition & 1 deletion test/src/unit-diagnostics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ TEST_CASE("Better diagnostics")
{
nlohmann::ordered_json j;
nlohmann::ordered_json j2;
const std::string value = "";
const std::string value;
j["first"] = value;
j["second"] = value;
j2["something"] = j;
Expand Down

0 comments on commit 200015c

Please sign in to comment.