🚨 fix warnings

This commit is contained in:
Niels Lohmann 2021-01-30 12:50:36 +01:00
parent 7b3ba241ab
commit b66ebcc950
No known key found for this signature in database
GPG Key ID: 7F3CEA63AE251B69
5 changed files with 19 additions and 15 deletions

View File

@ -365,7 +365,7 @@ The above example can also be expressed explicitly using [`json::parse()`](https
```cpp ```cpp
// parse explicitly // parse explicitly
auto j3 = json::parse("{ \"happy\": true, \"pi\": 3.141 }"); auto j3 = json::parse(R"({"happy": true, "pi": 3.141})");
``` ```
You can also get a string representation of a JSON value (serialize): You can also get a string representation of a JSON value (serialize):
@ -577,7 +577,7 @@ j[1] = 42;
bool foo = j.at(2); bool foo = j.at(2);
// comparison // comparison
j == "[\"foo\", 42, true]"_json; // true j == R"(["foo", 1, true])"_json; // true
// other stuff // other stuff
j.size(); // 3 entries j.size(); // 3 entries

View File

@ -396,8 +396,8 @@ struct from_json_fn
/// namespace to hold default `from_json` function /// namespace to hold default `from_json` function
/// to see why this is required: /// to see why this is required:
/// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4381.html /// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4381.html
namespace namespace // NOLINT(cert-dcl59-cpp,fuchsia-header-anon-namespaces,google-build-namespaces)
{ {
constexpr const auto& from_json = detail::static_const<detail::from_json_fn>::value; constexpr const auto& from_json = detail::static_const<detail::from_json_fn>::value; // NOLINT(misc-definitions-in-headers)
} // namespace } // namespace
} // namespace nlohmann } // namespace nlohmann

View File

@ -365,8 +365,10 @@ struct to_json_fn
} // namespace detail } // namespace detail
/// namespace to hold default `to_json` function /// namespace to hold default `to_json` function
namespace /// to see why this is required:
/// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4381.html
namespace // NOLINT(cert-dcl59-cpp,fuchsia-header-anon-namespaces,google-build-namespaces)
{ {
constexpr const auto& to_json = detail::static_const<detail::to_json_fn>::value; constexpr const auto& to_json = detail::static_const<detail::to_json_fn>::value; // NOLINT(misc-definitions-in-headers)
} // namespace } // namespace
} // namespace nlohmann } // namespace nlohmann

View File

@ -3878,9 +3878,9 @@ struct from_json_fn
/// namespace to hold default `from_json` function /// namespace to hold default `from_json` function
/// to see why this is required: /// to see why this is required:
/// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4381.html /// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4381.html
namespace namespace // NOLINT(cert-dcl59-cpp,fuchsia-header-anon-namespaces,google-build-namespaces)
{ {
constexpr const auto& from_json = detail::static_const<detail::from_json_fn>::value; constexpr const auto& from_json = detail::static_const<detail::from_json_fn>::value; // NOLINT(misc-definitions-in-headers)
} // namespace } // namespace
} // namespace nlohmann } // namespace nlohmann
@ -4439,9 +4439,11 @@ struct to_json_fn
} // namespace detail } // namespace detail
/// namespace to hold default `to_json` function /// namespace to hold default `to_json` function
namespace /// to see why this is required:
/// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4381.html
namespace // NOLINT(cert-dcl59-cpp,fuchsia-header-anon-namespaces,google-build-namespaces)
{ {
constexpr const auto& to_json = detail::static_const<detail::to_json_fn>::value; constexpr const auto& to_json = detail::static_const<detail::to_json_fn>::value; // NOLINT(misc-definitions-in-headers)
} // namespace } // namespace
} // namespace nlohmann } // namespace nlohmann

View File

@ -123,7 +123,7 @@ TEST_CASE("README" * doctest::skip())
{ {
// create object from string literal // create object from string literal
json j = "{ \"happy\": true, \"pi\": 3.141 }"_json; json j = "{ \"happy\": true, \"pi\": 3.141 }"_json; // NOLINT(modernize-raw-string-literal)
// or even nicer with a raw string literal // or even nicer with a raw string literal
auto j2 = R"( auto j2 = R"(
@ -134,7 +134,7 @@ TEST_CASE("README" * doctest::skip())
)"_json; )"_json;
// or explicitly // or explicitly
auto j3 = json::parse("{ \"happy\": true, \"pi\": 3.141 }"); auto j3 = json::parse(R"({"happy": true, "pi": 3.141})");
// explicit conversion to string // explicit conversion to string
std::string s = j.dump(); // {\"happy\":true,\"pi\":3.141} std::string s = j.dump(); // {\"happy\":true,\"pi\":3.141}
@ -158,17 +158,17 @@ TEST_CASE("README" * doctest::skip())
j.push_back(true); j.push_back(true);
// comparison // comparison
bool x = (j == "[\"foo\", 1, true]"_json); // true bool x = (j == R"(["foo", 1, true])"); // true
CHECK(x == true); CHECK(x == true);
// iterate the array // iterate the array
for (json::iterator it = j.begin(); it != j.end(); ++it) for (json::iterator it = j.begin(); it != j.end(); ++it) // NOLINT(modernize-loop-convert)
{ {
std::cout << *it << '\n'; std::cout << *it << '\n';
} }
// range-based for // range-based for
for (auto element : j) for (auto& element : j)
{ {
std::cout << element << '\n'; std::cout << element << '\n';
} }