diff --git a/include/fmt/format.h b/include/fmt/format.h index dcf71671..a4a07899 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -4136,33 +4136,37 @@ template struct formatter> : formatter { } }; -template struct nested_view { - const formatter* fmt; +template struct nested_view { + const formatter* fmt; const T* value; }; -template struct formatter> { - FMT_CONSTEXPR auto parse(format_parse_context& ctx) -> const char* { +template +struct formatter, Char> { + template + FMT_CONSTEXPR auto parse(ParseContext& ctx) -> decltype(ctx.begin()) { return ctx.begin(); } - auto format(nested_view view, format_context& ctx) const + template + auto format(nested_view view, FormatContext& ctx) const -> decltype(ctx.out()) { return view.fmt->format(*view.value, ctx); } }; -template struct nested_formatter { +template struct nested_formatter { private: int width_; detail::fill_t fill_; align_t align_ : 4; - formatter formatter_; + formatter formatter_; public: constexpr nested_formatter() : width_(0), align_(align_t::none) {} - FMT_CONSTEXPR auto parse(format_parse_context& ctx) -> const char* { - auto specs = detail::dynamic_format_specs(); + FMT_CONSTEXPR auto parse(basic_format_parse_context& ctx) + -> decltype(ctx.begin()) { + auto specs = detail::dynamic_format_specs(); auto it = parse_format_specs(ctx.begin(), ctx.end(), specs, ctx, detail::type::none_type); width_ = specs.width; @@ -4172,21 +4176,21 @@ template struct nested_formatter { return formatter_.parse(ctx); } - template - auto write_padded(format_context& ctx, F write) const -> decltype(ctx.out()) { + template + auto write_padded(FormatContext& ctx, F write) const -> decltype(ctx.out()) { if (width_ == 0) return write(ctx.out()); - auto buf = memory_buffer(); - write(appender(buf)); + auto buf = basic_memory_buffer(); + write(basic_appender(buf)); auto specs = format_specs(); specs.width = width_; specs.fill = fill_; specs.align = align_; - return detail::write(ctx.out(), string_view(buf.data(), buf.size()), - specs); + return detail::write( + ctx.out(), basic_string_view(buf.data(), buf.size()), specs); } - auto nested(const T& value) const -> nested_view { - return nested_view{&formatter_, &value}; + auto nested(const T& value) const -> nested_view { + return nested_view{&formatter_, &value}; } };