fix build

This commit is contained in:
Jin S 2024-02-23 14:28:25 -05:00
parent 7a8288d3a1
commit 181dbcf0b3

View File

@ -391,6 +391,7 @@ struct range_formatter<
detail::string_literal<Char, ']'>{}; detail::string_literal<Char, ']'>{};
bool is_string_format = false; bool is_string_format = false;
bool is_debug = false; bool is_debug = false;
public: public:
FMT_CONSTEXPR range_formatter() {} FMT_CONSTEXPR range_formatter() {}
@ -416,8 +417,7 @@ struct range_formatter<
if (it != end && *it == 'n') { if (it != end && *it == 'n') {
set_brackets({}, {}); set_brackets({}, {});
++it; ++it;
} } else {
else {
bool check_for_s = false; bool check_for_s = false;
if (it != end && *it == '?') { if (it != end && *it == '?') {
++it; ++it;
@ -427,16 +427,16 @@ struct range_formatter<
is_debug = true; is_debug = true;
} }
if (it != end && *it == 's') { if (it != end && *it == 's') {
if (!std::is_same<T,Char>::value) { if (!std::is_same<T, Char>::value) {
report_error("invalid format specifier"); report_error("invalid format specifier");
} }
if (!is_debug) { if (!is_debug) {
set_brackets(detail::string_literal<Char, '"'>{}, detail::string_literal<Char, '"'>{}); set_brackets(detail::string_literal<Char, '"'>{},
detail::string_literal<Char, '"'>{});
} }
check_for_s = false; check_for_s = false;
is_string_format = true; is_string_format = true;
++it; ++it;
} }
if (check_for_s) { if (check_for_s) {
report_error("invalid format specifier"); report_error("invalid format specifier");
@ -444,18 +444,19 @@ struct range_formatter<
} }
if (it != end && *it != '}') { if (it != end && *it != '}') {
if (is_string_format || *it != ':') report_error("invalid format specifier"); if (is_string_format || *it != ':')
report_error("invalid format specifier");
++it; ++it;
} else { } else {
if (!is_string_format) if (!is_string_format) detail::maybe_set_debug_format(underlying_, true);
detail::maybe_set_debug_format(underlying_, true);
} }
ctx.advance_to(it); ctx.advance_to(it);
return underlying_.parse(ctx); return underlying_.parse(ctx);
} }
template <typename R, typename FormatContext, typename U = T, enable_if_t<std::is_same<U,Char>::value, bool> = true> template <typename R, typename FormatContext, typename U = T,
enable_if_t<std::is_same<U, Char>::value, bool> = true>
auto format(R&& range, FormatContext& ctx) const -> decltype(ctx.out()) { auto format(R&& range, FormatContext& ctx) const -> decltype(ctx.out()) {
detail::range_mapper<buffered_context<Char>> mapper; detail::range_mapper<buffered_context<Char>> mapper;
auto out = ctx.out(); auto out = ctx.out();
@ -472,17 +473,16 @@ struct range_formatter<
} }
format_specs spec_str{}; format_specs spec_str{};
spec_str.type = presentation_type::debug; spec_str.type = presentation_type::debug;
detail::write<Char>(out, basic_string_view(buf.data(),buf.size()), spec_str); detail::write<Char>(out, basic_string_view<Char>(buf.data(), buf.size()),
} spec_str);
else { } else {
for (; it != end; ++it) { for (; it != end; ++it) {
ctx.advance_to(out); ctx.advance_to(out);
auto&& item = *it; auto&& item = *it;
out = underlying_.format(mapper.map(item), ctx); out = underlying_.format(mapper.map(item), ctx);
} }
} }
} } else {
else {
for (; it != end; ++it) { for (; it != end; ++it) {
if (i > 0) out = detail::copy<Char>(separator_, out); if (i > 0) out = detail::copy<Char>(separator_, out);
ctx.advance_to(out); ctx.advance_to(out);
@ -495,7 +495,8 @@ struct range_formatter<
return out; return out;
} }
template <typename R, typename FormatContext, typename U = T, enable_if_t<!(std::is_same<U,Char>::value), bool> = true> template <typename R, typename FormatContext, typename U = T,
enable_if_t<!(std::is_same<U, Char>::value), bool> = true>
auto format(R&& range, FormatContext& ctx) const -> decltype(ctx.out()) { auto format(R&& range, FormatContext& ctx) const -> decltype(ctx.out()) {
detail::range_mapper<buffered_context<Char>> mapper; detail::range_mapper<buffered_context<Char>> mapper;
auto out = ctx.out(); auto out = ctx.out();