From 67a4447fe31b3be462fa470b8efbbbb6e44c18b7 Mon Sep 17 00:00:00 2001 From: Walter Gray Date: Tue, 10 Nov 2020 17:35:50 -0800 Subject: [PATCH] fixup type errors --- include/fmt/chrono.h | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/include/fmt/chrono.h b/include/fmt/chrono.h index 2b80d136..2349fd8c 100644 --- a/include/fmt/chrono.h +++ b/include/fmt/chrono.h @@ -764,13 +764,20 @@ inline std::chrono::duration get_milliseconds( template OutputIt format_duration_value(OutputIt out, Rep val, int precision) { + using context = FMT_BUFFER_CONTEXT(type_identity_t); + const Char pr_f[] = {'{', ':', '.', '{', '}', 'f', '}', 0}; - if (precision >= 0) return vformat_to(out, pr_f, make_format_args(val, precision)); + if (precision >= 0) { + return vformat_to(out, to_string_view(pr_f), + make_format_args(val, precision)); + } const Char fp_f[] = {'{', ':', 'g', '}', 0}; const Char format[] = {'{', '}', 0}; - return vformat_to(out, std::is_floating_point::value ? fp_f : format, - make_format_args(val)); + return vformat_to( + out, to_string_view(std::is_floating_point::value ? fp_f : format), + make_format_args(val)); } + template OutputIt copy_unit(string_view unit, OutputIt out, Char) { return std::copy(unit.begin(), unit.end(), out); @@ -786,12 +793,19 @@ OutputIt copy_unit(string_view unit, OutputIt out, wchar_t) { template OutputIt format_duration_unit(OutputIt out) { - if (const char* unit = get_units()) + using context = FMT_BUFFER_CONTEXT(type_identity_t); + + if (const char* unit = get_units()) { return copy_unit(string_view(unit), out, Char()); + } const Char num_f[] = {'[', '{', '}', ']', 's', 0}; - if (const_check(Period::den == 1)) return vformat_to(out, num_f, make_format_args(Period::num)); + if (const_check(Period::den == 1)) { + return vformat_to(out, to_string_view(num_f), + make_format_args(Period::num)); + } const Char num_def_f[] = {'[', '{', '}', '/', '{', '}', ']', 's', 0}; - return vformat_to(out, num_def_f, make_format_args(Period::num, Period::den)); + return vformat_to(out, to_string_view(num_def_f), + make_format_args(Period::num, Period::den)); } template