@@ -403,33 +403,33 @@ namespace bencode {
403403 for (int i = 0 ; i != std::numeric_limits<Integer>::digits10; i++) {
404404 if (begin == end)
405405 throw end_of_input_error ();
406- if (!std::isdigit (*begin))
406+ if (!std::isdigit (static_cast < char >( *begin) ))
407407 return value;
408408
409409 if constexpr (std::is_signed_v<Integer>)
410- value = value * 10 + (*begin++ - u8 ' 0' ) * sgn;
410+ value = value * 10 + (static_cast < char8_t >( *begin++) - u8 ' 0' ) * sgn;
411411 else
412- value = value * 10 + (*begin++ - u8 ' 0' );
412+ value = value * 10 + (static_cast < char8_t >( *begin++) - u8 ' 0' );
413413 }
414414 if (begin == end)
415415 throw end_of_input_error ();
416416
417417 // We're approaching the limits of what `Integer` can hold. Check for
418418 // overflow.
419- if (std::isdigit (*begin)) {
419+ if (std::isdigit (static_cast < char >( *begin) )) {
420420 Integer digit;
421421 if constexpr (std::is_signed_v<Integer>) {
422- digit = (*begin++ - u8 ' 0' ) * sgn;
422+ digit = (static_cast < char8_t >( *begin++) - u8 ' 0' ) * sgn;
423423 check_over_underflow (value, digit, sgn);
424424 } else {
425- digit = (*begin++ - u8 ' 0' );
425+ digit = (static_cast < char8_t >( *begin++) - u8 ' 0' );
426426 check_overflow (value, digit);
427427 }
428428 value = value * 10 + digit;
429429 }
430430
431431 // Still more digits? That's too many!
432- if (std::isdigit (*begin)) {
432+ if (std::isdigit (static_cast < char >( *begin) )) {
433433 if (sgn == 1 )
434434 throw std::overflow_error (" integer overflow" );
435435 else
@@ -441,10 +441,10 @@ namespace bencode {
441441
442442 template <std::integral Integer, std::input_iterator Iter>
443443 Integer decode_int (Iter &begin, Iter end) {
444- assert (*begin == u8 ' i' );
444+ assert (static_cast < char8_t >( *begin) == u8 ' i' );
445445 ++begin;
446446 Integer sgn = 1 ;
447- if (*begin == u8 ' -' ) {
447+ if (static_cast < char8_t >( *begin) == u8 ' -' ) {
448448 if constexpr (std::is_unsigned_v<Integer>) {
449449 throw std::underflow_error (" expected unsigned integer" );
450450 } else {
@@ -454,7 +454,7 @@ namespace bencode {
454454 }
455455
456456 Integer value = decode_digits<Integer>(begin, end, sgn);
457- if (*begin != u8 ' e' )
457+ if (static_cast < char8_t >( *begin) != u8 ' e' )
458458 throw syntax_error (" expected 'e' token" );
459459
460460 ++begin;
@@ -498,11 +498,11 @@ namespace bencode {
498498
499499 template <typename String, std::input_iterator Iter>
500500 String decode_str (Iter &begin, Iter end) {
501- assert (std::isdigit (*begin));
501+ assert (std::isdigit (static_cast < char >( *begin) ));
502502 std::size_t len = decode_digits<std::size_t >(begin, end);
503503 if (begin == end)
504504 throw end_of_input_error ();
505- if (*begin != u8 ' :' )
505+ if (static_cast < char8_t >( *begin) != u8 ' :' )
506506 throw syntax_error (" expected ':' token" );
507507 ++begin;
508508
@@ -555,7 +555,7 @@ namespace bencode {
555555 if (begin == end)
556556 throw end_of_input_error ();
557557
558- if (*begin == u8 ' e' ) {
558+ if (static_cast < char8_t >( *begin) == u8 ' e' ) {
559559 if (!state.empty ()) {
560560 ++begin;
561561 state.pop ();
@@ -564,22 +564,22 @@ namespace bencode {
564564 }
565565 } else {
566566 if (!state.empty () && Traits::index (*state.top ()) == 3 /* dict */ ) {
567- if (!std::isdigit (*begin))
567+ if (!std::isdigit (static_cast < char >( *begin) ))
568568 throw syntax_error (" expected string start token for dict key" );
569569 dict_key = detail::decode_str<String>(begin, end);
570570 if (begin == end)
571571 throw end_of_input_error ();
572572 }
573573
574- if (*begin == u8 ' i' ) {
574+ if (static_cast < char8_t >( *begin) == u8 ' i' ) {
575575 store (detail::decode_int<Integer>(begin, end));
576- } else if (*begin == u8 ' l' ) {
576+ } else if (static_cast < char8_t >( *begin) == u8 ' l' ) {
577577 ++begin;
578578 state.push (store ( List{} ));
579- } else if (*begin == u8 ' d' ) {
579+ } else if (static_cast < char8_t >( *begin) == u8 ' d' ) {
580580 ++begin;
581581 state.push (store ( Dict{} ));
582- } else if (std::isdigit (*begin)) {
582+ } else if (std::isdigit (static_cast < char >( *begin) )) {
583583 store (detail::decode_str<String>(begin, end));
584584 } else {
585585 throw syntax_error (" unexpected type token" );
0 commit comments