Simplify to_ascii

This commit is contained in:
Victor Zverovich 2024-01-01 20:09:47 -08:00
parent 6c3b2d491e
commit 74ffea0dcf

View File

@ -2132,11 +2132,8 @@ struct dynamic_format_specs : format_specs<Char> {
};
// Converts a character to ASCII. Returns '\0' on conversion failure.
template <typename Char, FMT_ENABLE_IF(std::is_integral<Char>::value)>
constexpr auto to_ascii(Char c) -> char {
return c <= 0xff ? static_cast<char>(c) : '\0';
}
template <typename Char, FMT_ENABLE_IF(std::is_enum<Char>::value)>
template <typename Char, FMT_ENABLE_IF(std::is_integral<Char>::value ||
std::is_enum<Char>::value)>
constexpr auto to_ascii(Char c) -> char {
return c <= 0xff ? static_cast<char>(c) : '\0';
}