separate func for writing debug strings
This commit is contained in:
parent
556e412d3c
commit
5ebe8c8a69
@ -454,24 +454,36 @@ struct range_formatter<
|
||||
return underlying_.parse(ctx);
|
||||
}
|
||||
|
||||
template <typename Output, typename Iter, typename IterEnd, typename U = T,
|
||||
enable_if_t<std::is_same<U, Char>::value, bool> = true>
|
||||
auto write_debug_string(Output& out, Iter& it, IterEnd& end) const {
|
||||
auto buf = basic_memory_buffer<Char>();
|
||||
for (; it != end; ++it) {
|
||||
auto&& item = *it;
|
||||
buf.push_back(item);
|
||||
}
|
||||
format_specs spec_str{};
|
||||
spec_str.type = presentation_type::debug;
|
||||
detail::write<Char>(out, basic_string_view<Char>(buf.data(), buf.size()),
|
||||
spec_str);
|
||||
}
|
||||
template <typename Output, typename Iter, typename IterEnd, typename U = T,
|
||||
enable_if_t<!(std::is_same<U, Char>::value), bool> = true>
|
||||
auto write_debug_string(Output& out, Iter& it, IterEnd& end) const {
|
||||
detail::ignore_unused(out);
|
||||
detail::ignore_unused(it);
|
||||
detail::ignore_unused(end);
|
||||
}
|
||||
|
||||
template <typename R, typename FormatContext>
|
||||
auto format(R&& range, FormatContext& ctx) const -> decltype(ctx.out()) {
|
||||
detail::range_mapper<buffered_context<Char>> mapper;
|
||||
auto out = ctx.out();
|
||||
auto it = detail::range_begin(range);
|
||||
auto end = detail::range_end(range);
|
||||
if constexpr (std::is_same<T, Char>::value) {
|
||||
if (is_string_format && is_debug) {
|
||||
auto buf = basic_memory_buffer<Char>();
|
||||
for (; it != end; ++it) {
|
||||
auto&& item = *it;
|
||||
buf.push_back(item);
|
||||
}
|
||||
format_specs spec_str{};
|
||||
spec_str.type = presentation_type::debug;
|
||||
return detail::write<Char>(
|
||||
out, basic_string_view<Char>(buf.data(), buf.size()), spec_str);
|
||||
}
|
||||
if (is_string_format && is_debug) {
|
||||
write_debug_string(out, it, end);
|
||||
return out;
|
||||
}
|
||||
|
||||
out = detail::copy<Char>(opening_bracket_, out);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user