1
0
mirror of https://github.com/nlohmann/json.git synced 2025-08-06 07:02:42 +03:00

Modernize integer comparison (#4577)

Replace static_cast<size_t>(-1) with std::numeric_limits<std::size_t>::max()
via the detail::unknown_size() function
This commit is contained in:
Michael Valladolid
2025-01-02 01:01:38 +09:00
committed by GitHub
parent 2134cb947a
commit 4f64d8d0b4
5 changed files with 52 additions and 42 deletions

View File

@@ -751,10 +751,10 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
return it;
}
reference set_parent(reference j, std::size_t old_capacity = static_cast<std::size_t>(-1))
reference set_parent(reference j, std::size_t old_capacity = detail::unknown_size())
{
#if JSON_DIAGNOSTICS
if (old_capacity != static_cast<std::size_t>(-1))
if (old_capacity != detail::unknown_size())
{
// see https://github.com/nlohmann/json/issues/2838
JSON_ASSERT(type() == value_t::array);