diff --git a/test/scan.h b/test/scan.h index 50ac0941..061c5449 100644 --- a/test/scan.h +++ b/test/scan.h @@ -6,6 +6,7 @@ // For the license information refer to format.h. #include +#include #include "fmt/format.h" @@ -135,21 +136,20 @@ struct scan_handler : error_handler { char c = *it++; if (c < '0' || c > '9') on_error("invalid input"); // TODO: check overflow - value = value * 10 + (c - '0'); + value = value * 10 + static_cast(c - '0'); } scan_ctx_.advance_to(it); return value; } template T read_int() { - T value = 0; auto it = scan_ctx_.begin(), end = scan_ctx_.end(); bool negative = it != end && *it == '-'; if (negative) ++it; scan_ctx_.advance_to(it); - value = read_uint::type>(); - if (negative) value = -value; - return value; + const auto value = read_uint::type>(); + if (negative) return -static_cast(value); + return static_cast(value); } public: @@ -159,7 +159,7 @@ struct scan_handler : error_handler { const char* pos() const { return scan_ctx_.begin(); } void on_text(const char* begin, const char* end) { - auto size = end - begin; + auto size = static_cast(end - begin); auto it = scan_ctx_.begin(); if (it + size > scan_ctx_.end() || !std::equal(begin, end, make_checked(it, size))) { @@ -197,7 +197,7 @@ struct scan_handler : error_handler { case scan_type::string_view_type: { auto s = it; while (it != end && *it != ' ') ++it; - *arg_.string_view = fmt::string_view(s, it - s); + *arg_.string_view = fmt::string_view(s, static_cast(it - s)); scan_ctx_.advance_to(it); break; }