Fix handling of char
This commit is contained in:
@@ -2485,8 +2485,7 @@ FMT_CONSTEXPR FMT_INLINE auto parse_format_specs(
|
||||
if (specs.sign != sign::none) {
|
||||
require_numeric_argument(arg_type);
|
||||
if (is_integral_type(arg_type) && arg_type != type::int_type &&
|
||||
arg_type != type::long_long_type && arg_type != type::int128_type &&
|
||||
arg_type != type::char_type) {
|
||||
arg_type != type::long_long_type && arg_type != type::int128_type) {
|
||||
throw_format_error("format specifier requires signed argument");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1898,9 +1898,12 @@ template <typename Char, typename OutputIt>
|
||||
FMT_CONSTEXPR auto write(OutputIt out, Char value,
|
||||
const format_specs<Char>& specs, locale_ref loc = {})
|
||||
-> OutputIt {
|
||||
// char is formatted as unsigned char for consistency across platforms.
|
||||
using unsigned_type =
|
||||
conditional_t<std::is_same<Char, char>::value, unsigned char, unsigned>;
|
||||
return check_char_specs(specs)
|
||||
? write_char(out, value, specs)
|
||||
: write(out, static_cast<int>(value), specs, loc);
|
||||
: write(out, static_cast<unsigned_type>(value), specs, loc);
|
||||
}
|
||||
|
||||
// Data for write_int that doesn't depend on output iterator type. It is used to
|
||||
|
||||
Reference in New Issue
Block a user