Fix formatting

This commit is contained in:
Victor Zverovich 2020-12-24 06:54:33 -08:00
parent 4fa4c9248f
commit 1256541d7a
3 changed files with 6 additions and 18 deletions

View File

@ -783,7 +783,7 @@ OutputIt format_duration_value(OutputIt out, Rep val, int) {
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) {
basic_format_specs<Char> specs;
auto specs = basic_format_specs<Char>();
specs.precision = precision;
specs.type = precision > 0 ? 'f' : 'g';
return write<Char>(out, val, specs);
@ -806,15 +806,12 @@ 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());
*out++ = '[';
out = write<Char>(out, Period::num);
if (const_check(Period::den != 1)) {
*out++ = '/';
out = write<Char>(out, Period::den);
}
*out++ = ']';
*out++ = 's';
return out;

View File

@ -287,14 +287,10 @@ struct formatter<TupleT, Char, enable_if_t<fmt::is_tuple_like<TupleT>::value>> {
// C++11 generic lambda for format()
template <typename FormatContext> struct format_each {
template <typename T> void operator()(const T& v) {
if (i > 0) {
out = write_delimiter(out);
}
if (i > 0) out = write_delimiter(out);
out = detail::write_range_entry<Char>(out, v);
++i;
}
formatting_tuple<Char>& formatting;
size_t& i;
typename std::add_lvalue_reference<decltype(
@ -356,12 +352,8 @@ struct formatter<
auto it = view.begin();
auto end = view.end();
for (; it != end; ++it) {
if (i > 0) {
out = detail::write_delimiter(out);
}
if (i > 0) out = detail::write_delimiter(out);
out = detail::write_range_entry<Char>(out, *it);
if (++i > formatting.range_length_limit) {
out = format_to(out, FMT_STRING("{}"), " ... <other elements>");
break;

View File

@ -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