mirror of
https://github.com/nlohmann/json
synced 2024-11-21 19:50:04 +00:00
Fixed init-list construction when size_type is not int (#4140)
This commit is contained in:
parent
e75b94b31e
commit
6e36c721f0
@ -906,7 +906,10 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
bool is_an_object = std::all_of(init.begin(), init.end(),
|
||||
[](const detail::json_ref<basic_json>& element_ref)
|
||||
{
|
||||
return element_ref->is_array() && element_ref->size() == 2 && (*element_ref)[0].is_string();
|
||||
// The cast is to ensure op[size_type] is called, bearing in mind size_type may not be int;
|
||||
// (many string types can be constructed from 0 via its null-pointer guise, so we get a
|
||||
// broken call to op[key_type], the wrong semantics and a 4804 warning on Windows)
|
||||
return element_ref->is_array() && element_ref->size() == 2 && (*element_ref)[static_cast<size_type>(0)].is_string();
|
||||
});
|
||||
|
||||
// adjust type if type deduction is not wanted
|
||||
|
@ -20112,7 +20112,10 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
bool is_an_object = std::all_of(init.begin(), init.end(),
|
||||
[](const detail::json_ref<basic_json>& element_ref)
|
||||
{
|
||||
return element_ref->is_array() && element_ref->size() == 2 && (*element_ref)[0].is_string();
|
||||
// The cast is to ensure op[size_type] is called, bearing in mind size_type may not be int;
|
||||
// (many string types can be constructed from 0 via its null-pointer guise, so we get a
|
||||
// broken call to op[key_type], the wrong semantics and a 4804 warning on Windows)
|
||||
return element_ref->is_array() && element_ref->size() == 2 && (*element_ref)[static_cast<size_type>(0)].is_string();
|
||||
});
|
||||
|
||||
// adjust type if type deduction is not wanted
|
||||
|
Loading…
Reference in New Issue
Block a user