@@ -8774,7 +8774,7 @@ class json_sax_dom_parser
8774
8774
}
8775
8775
#endif
8776
8776
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()))
8778
8778
{
8779
8779
JSON_THROW(out_of_range::create(408, concat("excessive object size: ", std::to_string(len)), ref_stack.back()));
8780
8780
}
@@ -8823,7 +8823,7 @@ class json_sax_dom_parser
8823
8823
}
8824
8824
#endif
8825
8825
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()))
8827
8827
{
8828
8828
JSON_THROW(out_of_range::create(408, concat("excessive array size: ", std::to_string(len)), ref_stack.back()));
8829
8829
}
@@ -9091,7 +9091,7 @@ class json_sax_dom_callback_parser
9091
9091
#endif
9092
9092
9093
9093
// 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()))
9095
9095
{
9096
9096
JSON_THROW(out_of_range::create(408, concat("excessive object size: ", std::to_string(len)), ref_stack.back()));
9097
9097
}
@@ -9189,7 +9189,7 @@ class json_sax_dom_callback_parser
9189
9189
#endif
9190
9190
9191
9191
// 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()))
9193
9193
{
9194
9194
JSON_THROW(out_of_range::create(408, concat("excessive array size: ", std::to_string(len)), ref_stack.back()));
9195
9195
}
@@ -9478,7 +9478,7 @@ class json_sax_acceptor
9478
9478
return true;
9479
9479
}
9480
9480
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( ))
9482
9482
{
9483
9483
return true;
9484
9484
}
@@ -9493,7 +9493,7 @@ class json_sax_acceptor
9493
9493
return true;
9494
9494
}
9495
9495
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( ))
9497
9497
{
9498
9498
return true;
9499
9499
}
@@ -9825,7 +9825,7 @@ class binary_reader
9825
9825
std::int32_t document_size{};
9826
9826
get_number<std::int32_t, true>(input_format_t::bson, document_size);
9827
9827
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( ))))
9829
9829
{
9830
9830
return false;
9831
9831
}
@@ -10047,7 +10047,7 @@ class binary_reader
10047
10047
std::int32_t document_size{};
10048
10048
get_number<std::int32_t, true>(input_format_t::bson, document_size);
10049
10049
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( ))))
10051
10051
{
10052
10052
return false;
10053
10053
}
@@ -10307,7 +10307,7 @@ class binary_reader
10307
10307
}
10308
10308
10309
10309
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);
10311
10311
10312
10312
// map (0x00..0x17 pairs of data items follow)
10313
10313
case 0xA0:
@@ -10361,7 +10361,7 @@ class binary_reader
10361
10361
}
10362
10362
10363
10363
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);
10365
10365
10366
10366
case 0xC6: // tagged item
10367
10367
case 0xC7:
@@ -10749,7 +10749,7 @@ class binary_reader
10749
10749
}
10750
10750
10751
10751
/*!
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
10753
10753
array of indefinite size
10754
10754
@param[in] tag_handler how CBOR tags should be treated
10755
10755
@return whether array creation completed
@@ -10762,7 +10762,7 @@ class binary_reader
10762
10762
return false;
10763
10763
}
10764
10764
10765
- if (len != static_cast <std::size_t>(-1 ))
10765
+ if (len != std::numeric_limits <std::size_t>::max( ))
10766
10766
{
10767
10767
for (std::size_t i = 0; i < len; ++i)
10768
10768
{
@@ -10787,7 +10787,7 @@ class binary_reader
10787
10787
}
10788
10788
10789
10789
/*!
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
10791
10791
object of indefinite size
10792
10792
@param[in] tag_handler how CBOR tags should be treated
10793
10793
@return whether object creation completed
@@ -10803,7 +10803,7 @@ class binary_reader
10803
10803
if (len != 0)
10804
10804
{
10805
10805
string_t key;
10806
- if (len != static_cast <std::size_t>(-1 ))
10806
+ if (len != std::numeric_limits <std::size_t>::max( ))
10807
10807
{
10808
10808
for (std::size_t i = 0; i < len; ++i)
10809
10809
{
@@ -12221,7 +12221,7 @@ class binary_reader
12221
12221
}
12222
12222
else
12223
12223
{
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( ))))
12225
12225
{
12226
12226
return false;
12227
12227
}
@@ -12299,7 +12299,7 @@ class binary_reader
12299
12299
}
12300
12300
else
12301
12301
{
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( ))))
12303
12303
{
12304
12304
return false;
12305
12305
}
@@ -12635,7 +12635,7 @@ class binary_reader
12635
12635
}
12636
12636
12637
12637
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( );
12639
12639
12640
12640
/// input adapter
12641
12641
InputAdapterType ia;
@@ -12905,7 +12905,7 @@ class parser
12905
12905
{
12906
12906
case token_type::begin_object:
12907
12907
{
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( ))))
12909
12909
{
12910
12910
return false;
12911
12911
}
@@ -12950,7 +12950,7 @@ class parser
12950
12950
12951
12951
case token_type::begin_array:
12952
12952
{
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( ))))
12954
12954
{
12955
12955
return false;
12956
12956
}
@@ -20606,10 +20606,10 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
20606
20606
return it;
20607
20607
}
20608
20608
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( ))
20610
20610
{
20611
20611
#if JSON_DIAGNOSTICS
20612
- if (old_capacity != static_cast <std::size_t>(-1 ))
20612
+ if (old_capacity != std::numeric_limits <std::size_t>::max( ))
20613
20613
{
20614
20614
// see https://github.com/nlohmann/json/issues/2838
20615
20615
JSON_ASSERT(type() == value_t::array);
0 commit comments