diff --git a/include/fmt/ranges.h b/include/fmt/ranges.h index 128a7aa7..ff3d3a47 100644 --- a/include/fmt/ranges.h +++ b/include/fmt/ranges.h @@ -391,6 +391,7 @@ struct range_formatter< detail::string_literal{}; bool is_string_format = false; bool is_debug = false; + public: FMT_CONSTEXPR range_formatter() {} @@ -416,8 +417,7 @@ struct range_formatter< if (it != end && *it == 'n') { set_brackets({}, {}); ++it; - } - else { + } else { bool check_for_s = false; if (it != end && *it == '?') { ++it; @@ -427,35 +427,36 @@ struct range_formatter< is_debug = true; } if (it != end && *it == 's') { - if (!std::is_same::value) { + if (!std::is_same::value) { report_error("invalid format specifier"); } if (!is_debug) { - set_brackets(detail::string_literal{}, detail::string_literal{}); + set_brackets(detail::string_literal{}, + detail::string_literal{}); } check_for_s = false; is_string_format = true; - ++it; - + ++it; } - if (check_for_s) { + if (check_for_s) { report_error("invalid format specifier"); - } + } } - if (it != end && *it != '}') { - if (is_string_format || *it != ':') report_error("invalid format specifier"); + if (it != end && *it != '}') { + if (is_string_format || *it != ':') + report_error("invalid format specifier"); ++it; } else { - if (!is_string_format) - detail::maybe_set_debug_format(underlying_, true); + if (!is_string_format) detail::maybe_set_debug_format(underlying_, true); } ctx.advance_to(it); return underlying_.parse(ctx); } - template ::value, bool> = true> + template ::value, bool> = true> auto format(R&& range, FormatContext& ctx) const -> decltype(ctx.out()) { detail::range_mapper> mapper; auto out = ctx.out(); @@ -472,22 +473,21 @@ struct range_formatter< } format_specs spec_str{}; spec_str.type = presentation_type::debug; - detail::write(out, basic_string_view(buf.data(),buf.size()), spec_str); - } - else { + detail::write(out, basic_string_view(buf.data(), buf.size()), + spec_str); + } else { for (; it != end; ++it) { ctx.advance_to(out); auto&& item = *it; - out = underlying_.format(mapper.map(item), ctx); + out = underlying_.format(mapper.map(item), ctx); } } - } - else { + } else { for (; it != end; ++it) { if (i > 0) out = detail::copy(separator_, out); ctx.advance_to(out); auto&& item = *it; - out = underlying_.format(mapper.map(item), ctx); + out = underlying_.format(mapper.map(item), ctx); ++i; } } @@ -495,7 +495,8 @@ struct range_formatter< return out; } - template ::value), bool> = true> + template ::value), bool> = true> auto format(R&& range, FormatContext& ctx) const -> decltype(ctx.out()) { detail::range_mapper> mapper; auto out = ctx.out(); @@ -507,7 +508,7 @@ struct range_formatter< if (i > 0) out = detail::copy(separator_, out); ctx.advance_to(out); auto&& item = *it; - out = underlying_.format(mapper.map(item), ctx); + out = underlying_.format(mapper.map(item), ctx); ++i; } out = detail::copy(closing_bracket_, out);