remove vformat from chrono.h

This commit is contained in:
Walter Gray 2020-12-20 16:26:53 -08:00
parent c85d5e342c
commit b9063f9392

View File

@ -768,24 +768,16 @@ inline std::chrono::duration<Rep, std::milli> get_milliseconds(
template <typename Char, typename Rep, typename OutputIt,
FMT_ENABLE_IF(std::is_integral<Rep>::value)>
OutputIt format_duration_value(OutputIt out, Rep val, int) {
static FMT_CONSTEXPR_DECL const Char format[] = {'{', '}', 0};
return vformat_to(out, to_string_view(format),
make_format_args<buffer_context<Char>>(val));
return write<Char>(out, val);
}
template <typename Char, typename Rep, typename OutputIt,
FMT_ENABLE_IF(std::is_floating_point<Rep>::value)>
OutputIt format_duration_value(OutputIt out, Rep val, int precision) {
static FMT_CONSTEXPR_DECL const Char pr_f[] = {'{', ':', '.', '{',
'}', 'f', '}', 0};
if (precision >= 0) {
return vformat_to(out, to_string_view(pr_f),
make_format_args<buffer_context<Char>>(val, precision));
}
static FMT_CONSTEXPR_DECL const Char fp_f[] = {'{', ':', 'g', '}', 0};
return vformat_to(out, to_string_view(fp_f),
make_format_args<buffer_context<Char>>(val));
basic_format_specs<Char> specs;
specs.precision = precision;
specs.type = precision > 0 ? 'f' : 'g';
return write<Char>(out, val, specs);
}
template <typename Char, typename OutputIt>
@ -805,16 +797,20 @@ template <typename Char, typename Period, typename OutputIt>
OutputIt format_duration_unit(OutputIt out) {
if (const char* unit = get_units<Period>())
return copy_unit(string_view(unit), out, Char());
static FMT_CONSTEXPR_DECL const Char num_f[] = {'[', '{', '}', ']', 's', 0};
if (const_check(Period::den == 1)) {
return vformat_to(out, to_string_view(num_f),
make_format_args<buffer_context<Char>>(Period::num));
basic_memory_buffer<Char> buffer;
auto bufOut = std::back_inserter(buffer);
*bufOut++ = '[';
bufOut = write<Char>(bufOut, Period::num);
if (const_check(Period::den != 1)) {
*bufOut++ = '/';
bufOut = write<Char>(bufOut, Period::den);
}
static FMT_CONSTEXPR_DECL const Char num_def_f[] = {'[', '{', '}', '/', '{',
'}', ']', 's', 0};
return vformat_to(
out, to_string_view(num_def_f),
make_format_args<buffer_context<Char>>(Period::num, Period::den));
*bufOut++ = ']';
*bufOut++ = 's';
return write<Char>(out, {buffer.data(), buffer.size()});
}
template <typename FormatContext, typename OutputIt, typename Rep,