@@ -8774,7 +8774,7 @@ class json_sax_dom_parser
87748774 }
87758775#endif
87768776
8777- if (JSON_HEDLEY_UNLIKELY(len != static_cast <std::size_t>(-1 ) && len > ref_stack.back()->max_size()))
8777+ if (JSON_HEDLEY_UNLIKELY(len != std::numeric_limits <std::size_t>::max( ) && len > ref_stack.back()->max_size()))
87788778 {
87798779 JSON_THROW(out_of_range::create(408, concat("excessive object size: ", std::to_string(len)), ref_stack.back()));
87808780 }
@@ -8823,7 +8823,7 @@ class json_sax_dom_parser
88238823 }
88248824#endif
88258825
8826- if (JSON_HEDLEY_UNLIKELY(len != static_cast <std::size_t>(-1 ) && len > ref_stack.back()->max_size()))
8826+ if (JSON_HEDLEY_UNLIKELY(len != std::numeric_limits <std::size_t>::max( ) && len > ref_stack.back()->max_size()))
88278827 {
88288828 JSON_THROW(out_of_range::create(408, concat("excessive array size: ", std::to_string(len)), ref_stack.back()));
88298829 }
@@ -9091,7 +9091,7 @@ class json_sax_dom_callback_parser
90919091#endif
90929092
90939093 // check object limit
9094- if (JSON_HEDLEY_UNLIKELY(len != static_cast <std::size_t>(-1 ) && len > ref_stack.back()->max_size()))
9094+ if (JSON_HEDLEY_UNLIKELY(len != std::numeric_limits <std::size_t>::max( ) && len > ref_stack.back()->max_size()))
90959095 {
90969096 JSON_THROW(out_of_range::create(408, concat("excessive object size: ", std::to_string(len)), ref_stack.back()));
90979097 }
@@ -9189,7 +9189,7 @@ class json_sax_dom_callback_parser
91899189#endif
91909190
91919191 // check array limit
9192- if (JSON_HEDLEY_UNLIKELY(len != static_cast <std::size_t>(-1 ) && len > ref_stack.back()->max_size()))
9192+ if (JSON_HEDLEY_UNLIKELY(len != std::numeric_limits <std::size_t>::max( ) && len > ref_stack.back()->max_size()))
91939193 {
91949194 JSON_THROW(out_of_range::create(408, concat("excessive array size: ", std::to_string(len)), ref_stack.back()));
91959195 }
@@ -9478,7 +9478,7 @@ class json_sax_acceptor
94789478 return true;
94799479 }
94809480
9481- bool start_object(std::size_t /*unused*/ = static_cast <std::size_t>(-1 ))
9481+ bool start_object(std::size_t /*unused*/ = std::numeric_limits <std::size_t>::max( ))
94829482 {
94839483 return true;
94849484 }
@@ -9493,7 +9493,7 @@ class json_sax_acceptor
94939493 return true;
94949494 }
94959495
9496- bool start_array(std::size_t /*unused*/ = static_cast <std::size_t>(-1 ))
9496+ bool start_array(std::size_t /*unused*/ = std::numeric_limits <std::size_t>::max( ))
94979497 {
94989498 return true;
94999499 }
@@ -9825,7 +9825,7 @@ class binary_reader
98259825 std::int32_t document_size{};
98269826 get_number<std::int32_t, true>(input_format_t::bson, document_size);
98279827
9828- if (JSON_HEDLEY_UNLIKELY(!sax->start_object(static_cast <std::size_t>(-1 ))))
9828+ if (JSON_HEDLEY_UNLIKELY(!sax->start_object(std::numeric_limits <std::size_t>::max( ))))
98299829 {
98309830 return false;
98319831 }
@@ -10047,7 +10047,7 @@ class binary_reader
1004710047 std::int32_t document_size{};
1004810048 get_number<std::int32_t, true>(input_format_t::bson, document_size);
1004910049
10050- if (JSON_HEDLEY_UNLIKELY(!sax->start_array(static_cast <std::size_t>(-1 ))))
10050+ if (JSON_HEDLEY_UNLIKELY(!sax->start_array(std::numeric_limits <std::size_t>::max( ))))
1005110051 {
1005210052 return false;
1005310053 }
@@ -10307,7 +10307,7 @@ class binary_reader
1030710307 }
1030810308
1030910309 case 0x9F: // array (indefinite length)
10310- return get_cbor_array(static_cast <std::size_t>(-1 ), tag_handler);
10310+ return get_cbor_array(std::numeric_limits <std::size_t>::max( ), tag_handler);
1031110311
1031210312 // map (0x00..0x17 pairs of data items follow)
1031310313 case 0xA0:
@@ -10361,7 +10361,7 @@ class binary_reader
1036110361 }
1036210362
1036310363 case 0xBF: // map (indefinite length)
10364- return get_cbor_object(static_cast <std::size_t>(-1 ), tag_handler);
10364+ return get_cbor_object(std::numeric_limits <std::size_t>::max( ), tag_handler);
1036510365
1036610366 case 0xC6: // tagged item
1036710367 case 0xC7:
@@ -10749,7 +10749,7 @@ class binary_reader
1074910749 }
1075010750
1075110751 /*!
10752- @param[in] len the length of the array or static_cast <std::size_t>(-1 ) for an
10752+ @param[in] len the length of the array or std::numeric_limits <std::size_t>::max( ) for an
1075310753 array of indefinite size
1075410754 @param[in] tag_handler how CBOR tags should be treated
1075510755 @return whether array creation completed
@@ -10762,7 +10762,7 @@ class binary_reader
1076210762 return false;
1076310763 }
1076410764
10765- if (len != static_cast <std::size_t>(-1 ))
10765+ if (len != std::numeric_limits <std::size_t>::max( ))
1076610766 {
1076710767 for (std::size_t i = 0; i < len; ++i)
1076810768 {
@@ -10787,7 +10787,7 @@ class binary_reader
1078710787 }
1078810788
1078910789 /*!
10790- @param[in] len the length of the object or static_cast <std::size_t>(-1 ) for an
10790+ @param[in] len the length of the object or std::numeric_limits <std::size_t>::max( ) for an
1079110791 object of indefinite size
1079210792 @param[in] tag_handler how CBOR tags should be treated
1079310793 @return whether object creation completed
@@ -10803,7 +10803,7 @@ class binary_reader
1080310803 if (len != 0)
1080410804 {
1080510805 string_t key;
10806- if (len != static_cast <std::size_t>(-1 ))
10806+ if (len != std::numeric_limits <std::size_t>::max( ))
1080710807 {
1080810808 for (std::size_t i = 0; i < len; ++i)
1080910809 {
@@ -12221,7 +12221,7 @@ class binary_reader
1222112221 }
1222212222 else
1222312223 {
12224- if (JSON_HEDLEY_UNLIKELY(!sax->start_array(static_cast <std::size_t>(-1 ))))
12224+ if (JSON_HEDLEY_UNLIKELY(!sax->start_array(std::numeric_limits <std::size_t>::max( ))))
1222512225 {
1222612226 return false;
1222712227 }
@@ -12299,7 +12299,7 @@ class binary_reader
1229912299 }
1230012300 else
1230112301 {
12302- if (JSON_HEDLEY_UNLIKELY(!sax->start_object(static_cast <std::size_t>(-1 ))))
12302+ if (JSON_HEDLEY_UNLIKELY(!sax->start_object(std::numeric_limits <std::size_t>::max( ))))
1230312303 {
1230412304 return false;
1230512305 }
@@ -12635,7 +12635,7 @@ class binary_reader
1263512635 }
1263612636
1263712637 private:
12638- static JSON_INLINE_VARIABLE constexpr std::size_t npos = static_cast <std::size_t>(-1 );
12638+ static JSON_INLINE_VARIABLE constexpr std::size_t npos = std::numeric_limits <std::size_t>::max( );
1263912639
1264012640 /// input adapter
1264112641 InputAdapterType ia;
@@ -12905,7 +12905,7 @@ class parser
1290512905 {
1290612906 case token_type::begin_object:
1290712907 {
12908- if (JSON_HEDLEY_UNLIKELY(!sax->start_object(static_cast <std::size_t>(-1 ))))
12908+ if (JSON_HEDLEY_UNLIKELY(!sax->start_object(std::numeric_limits <std::size_t>::max( ))))
1290912909 {
1291012910 return false;
1291112911 }
@@ -12950,7 +12950,7 @@ class parser
1295012950
1295112951 case token_type::begin_array:
1295212952 {
12953- if (JSON_HEDLEY_UNLIKELY(!sax->start_array(static_cast <std::size_t>(-1 ))))
12953+ if (JSON_HEDLEY_UNLIKELY(!sax->start_array(std::numeric_limits <std::size_t>::max( ))))
1295412954 {
1295512955 return false;
1295612956 }
@@ -20606,10 +20606,10 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
2060620606 return it;
2060720607 }
2060820608
20609- reference set_parent(reference j, std::size_t old_capacity = static_cast <std::size_t>(-1 ))
20609+ reference set_parent(reference j, std::size_t old_capacity = std::numeric_limits <std::size_t>::max( ))
2061020610 {
2061120611#if JSON_DIAGNOSTICS
20612- if (old_capacity != static_cast <std::size_t>(-1 ))
20612+ if (old_capacity != std::numeric_limits <std::size_t>::max( ))
2061320613 {
2061420614 // see https://github.com/nlohmann/json/issues/2838
2061520615 JSON_ASSERT(type() == value_t::array);
0 commit comments