Fix build

This commit is contained in:
Shawn Zhong 2023-01-13 04:24:45 -06:00
parent 43c2eae78d
commit 6a0f6ff708

View File

@ -677,16 +677,15 @@ enum class pad_type {
}; };
template <typename OutputIt> template <typename OutputIt>
auto write_padding(OutputIt out, int width, pad_type pad) { auto write_padding(OutputIt out, pad_type pad, int width) -> OutputIt {
switch (pad) { if (pad == pad_type::none) return out;
case pad_type::zero: return std::fill_n(out, width, pad == pad_type::space ? ' ' : '0');
case pad_type::unspecified: }
return std::fill_n(out, width, '0');
case pad_type::space: template <typename OutputIt>
return std::fill_n(out, width, ' '); auto write_padding(OutputIt out, pad_type pad) -> OutputIt {
case pad_type::none: if (pad != pad_type::none) *out++ = pad == pad_type::space ? ' ' : '0';
return out; return out;
}
} }
// Parses a put_time-like format string and invokes handler actions. // Parses a put_time-like format string and invokes handler actions.
@ -1279,26 +1278,14 @@ class tm_writer {
*out_++ = *d; *out_++ = *d;
} }
void write2(int value, pad_type pad) { void write2(int value, pad_type pad) {
switch (pad) { unsigned int v = to_unsigned(value) % 100;
case pad_type::unspecified: if (v >= 10) {
case pad_type::zero: const char* d = digits2(v);
write2(value); *out_++ = *d++;
break; *out_++ = *d;
case pad_type::space: } else {
if (value < 10) { out_ = detail::write_padding(out_, pad);
*out_++ = ' '; *out_++ = static_cast<char>('0' + v);
write1(value);
} else {
write2(value);
}
break;
case pad_type::none:
if (value < 10) {
write1(value);
} else {
write2(value);
}
break;
} }
} }
@ -1891,7 +1878,7 @@ struct chrono_formatter {
to_unsigned(to_nonnegative_int(value, max_value<int>())); to_unsigned(to_nonnegative_int(value, max_value<int>()));
int num_digits = detail::count_digits(n); int num_digits = detail::count_digits(n);
if (width > num_digits) { if (width > num_digits) {
out = detail::write_padding(out, width - num_digits, pad); out = detail::write_padding(out, pad, width - num_digits);
} }
out = format_decimal<char_type>(out, n, num_digits).end; out = format_decimal<char_type>(out, n, num_digits).end;
} }
@ -1978,7 +1965,7 @@ struct chrono_formatter {
precision); precision);
if (negative) *out++ = '-'; if (negative) *out++ = '-';
if (buf.size() < 2 || buf[1] == '.') { if (buf.size() < 2 || buf[1] == '.') {
out = detail::write_padding(out, 1, pad); out = detail::write_padding(out, pad);
} }
out = std::copy(buf.begin(), buf.end(), out); out = std::copy(buf.begin(), buf.end(), out);
} else { } else {