From 1256541d7a13d56fd9ce379a770a575fd6aa2c85 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Thu, 24 Dec 2020 06:54:33 -0800 Subject: [PATCH] Fix formatting --- include/fmt/chrono.h | 5 +---- include/fmt/ranges.h | 12 ++---------- test/CMakeLists.txt | 7 +++---- 3 files changed, 6 insertions(+), 18 deletions(-) diff --git a/include/fmt/chrono.h b/include/fmt/chrono.h index 3b4267ea..0e06e18c 100644 --- a/include/fmt/chrono.h +++ b/include/fmt/chrono.h @@ -783,7 +783,7 @@ OutputIt format_duration_value(OutputIt out, Rep val, int) { template ::value)> OutputIt format_duration_value(OutputIt out, Rep val, int precision) { - basic_format_specs specs; + auto specs = basic_format_specs(); specs.precision = precision; specs.type = precision > 0 ? 'f' : 'g'; return write(out, val, specs); @@ -806,15 +806,12 @@ template OutputIt format_duration_unit(OutputIt out) { if (const char* unit = get_units()) return copy_unit(string_view(unit), out, Char()); - *out++ = '['; out = write(out, Period::num); - if (const_check(Period::den != 1)) { *out++ = '/'; out = write(out, Period::den); } - *out++ = ']'; *out++ = 's'; return out; diff --git a/include/fmt/ranges.h b/include/fmt/ranges.h index 91f55e0b..14c63e78 100644 --- a/include/fmt/ranges.h +++ b/include/fmt/ranges.h @@ -287,14 +287,10 @@ struct formatter::value>> { // C++11 generic lambda for format() template struct format_each { template void operator()(const T& v) { - if (i > 0) { - out = write_delimiter(out); - } - + if (i > 0) out = write_delimiter(out); out = detail::write_range_entry(out, v); ++i; } - formatting_tuple& formatting; size_t& i; typename std::add_lvalue_reference 0) { - out = detail::write_delimiter(out); - } - + if (i > 0) out = detail::write_delimiter(out); out = detail::write_range_entry(out, *it); - if (++i > formatting.range_length_limit) { out = format_to(out, FMT_STRING("{}"), " ... "); break; diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 78798d87..b4ba9794 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -107,12 +107,11 @@ add_fmt_test(ranges-test) add_fmt_test(scan-test) if (NOT MSVC) - # FMT_ENFORCE_COMPILE_STRING not supported under MSVC - # See https://developercommunity.visualstudio.com/content/problem/1277597/internal-compiler-c0001-error-on-complex-nested-la.html + # FMT_ENFORCE_COMPILE_STRING is not supported under MSVC due to compiler bugs. add_fmt_test(enforce-compile-string-test) target_compile_definitions(enforce-compile-string-test PRIVATE - "-DFMT_ENFORCE_COMPILE_STRING") -endif() + -DFMT_ENFORCE_COMPILE_STRING) +endif () if (NOT DEFINED MSVC_STATIC_RUNTIME AND MSVC) foreach (flag_var