Remove a redundant extension to reduce divergence from std::format

This commit is contained in:
Victor Zverovich
2024-06-08 08:29:34 -07:00
parent 21372bc0b2
commit 7bd11b5cdf
2 changed files with 7 additions and 21 deletions

View File

@@ -676,12 +676,10 @@ enum class numeric_system {
// Glibc extensions for formatting numeric values.
enum class pad_type {
unspecified,
// Pad a numeric result string with zeros (the default).
zero,
// Do not pad a numeric result string.
none,
// Pad a numeric result string with zeros even if the conversion specifier
// character uses space-padding by default.
zero,
// Pad a numeric result string with spaces.
space,
};
@@ -706,7 +704,7 @@ FMT_CONSTEXPR auto parse_chrono_format(const Char* begin, const Char* end,
if (*begin != '%') FMT_THROW(format_error("invalid format"));
auto ptr = begin;
while (ptr != end) {
pad_type pad = pad_type::unspecified;
pad_type pad = pad_type::zero;
auto c = *ptr;
if (c == '}') break;
if (c != '%') {
@@ -726,10 +724,6 @@ FMT_CONSTEXPR auto parse_chrono_format(const Char* begin, const Char* end,
pad = pad_type::none;
++ptr;
break;
case '0':
pad = pad_type::zero;
++ptr;
break;
}
if (ptr == end) FMT_THROW(format_error("invalid format"));
c = *ptr++;
@@ -1637,7 +1631,7 @@ class tm_writer {
void on_iso_time() {
on_24_hour_time();
*out_++ = ':';
on_second(numeric_system::standard, pad_type::unspecified);
on_second(numeric_system::standard, pad_type::zero);
}
void on_am_pm() {
@@ -1878,7 +1872,7 @@ struct chrono_formatter {
}
}
void write(Rep value, int width, pad_type pad = pad_type::unspecified) {
void write(Rep value, int width, pad_type pad = pad_type::zero) {
write_sign();
if (isnan(value)) return write_nan();
uint32_or_64_or_128_t<int> n =
@@ -2011,7 +2005,7 @@ struct chrono_formatter {
on_24_hour_time();
*out++ = ':';
if (handle_nan_inf()) return;
on_second(numeric_system::standard, pad_type::unspecified);
on_second(numeric_system::standard, pad_type::zero);
}
void on_am_pm() {
@@ -2151,7 +2145,7 @@ struct formatter<day, Char> : private formatter<std::tm, Char> {
detail::get_locale loc(false, ctx.locale());
auto w = detail::tm_writer<decltype(ctx.out()), Char>(loc, ctx.out(), time);
w.on_day_of_month(detail::numeric_system::standard,
detail::pad_type::unspecified);
detail::pad_type::zero);
return w.out();
}
};