From 7d22bebb6f16e4bb135fcb100d523e09f5eb613a Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Fri, 29 May 2020 21:30:20 -0700 Subject: [PATCH] Remove uses of buffer_range --- include/fmt/compile.h | 29 ++++++++++++++--------------- include/fmt/format.h | 2 +- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/include/fmt/compile.h b/include/fmt/compile.h index 0235cbc1..03a819bc 100644 --- a/include/fmt/compile.h +++ b/include/fmt/compile.h @@ -160,25 +160,25 @@ FMT_CONSTEXPR void compile_format_string(basic_string_view format_str, format_string_compiler(format_str, handler)); } -template +template void format_arg( - basic_format_parse_context& parse_ctx, + basic_format_parse_context& parse_ctx, Context& ctx, Id arg_id) { ctx.advance_to(visit_format_arg( - arg_formatter( + arg_formatter( ctx, &parse_ctx), ctx.arg(arg_id))); } // vformat_to is defined in a subnamespace to prevent ADL. namespace cf { -template -auto vformat_to(Range out, CompiledFormat& cf, basic_format_args args) +template +auto vformat_to(OutputIt out, CompiledFormat& cf, basic_format_args args) -> typename Context::iterator { using char_type = typename Context::char_type; basic_format_parse_context parse_ctx( to_string_view(cf.format_str_)); - Context ctx(out.begin(), args); + Context ctx(out, args); const auto& parts = cf.parts(); for (auto part_it = std::begin(parts); part_it != std::end(parts); @@ -199,12 +199,12 @@ auto vformat_to(Range out, CompiledFormat& cf, basic_format_args args) case format_part_t::kind::arg_index: advance_to(parse_ctx, part.arg_id_end); - detail::format_arg(parse_ctx, ctx, value.arg_index); + detail::format_arg(parse_ctx, ctx, value.arg_index); break; case format_part_t::kind::arg_name: advance_to(parse_ctx, part.arg_id_end); - detail::format_arg(parse_ctx, ctx, value.str); + detail::format_arg(parse_ctx, ctx, value.str); break; case format_part_t::kind::replacement: { @@ -228,7 +228,7 @@ auto vformat_to(Range out, CompiledFormat& cf, basic_format_args args) advance_to(parse_ctx, part.arg_id_end); ctx.advance_to(visit_format_arg( - arg_formatter( + arg_formatter( ctx, nullptr, &specs), arg)); break; @@ -322,8 +322,8 @@ class compiled_format : private compiled_format_base { private: basic_string_view format_str_; - template - friend auto cf::vformat_to(Range out, CompiledFormat& cf, + template + friend auto cf::vformat_to(OutputIt out, CompiledFormat& cf, basic_format_args args) -> typename Context::iterator; @@ -558,9 +558,9 @@ template ::value)> std::basic_string format(const CompiledFormat& cf, const Args&... args) { basic_memory_buffer buffer; - using range = buffer_range; using context = buffer_context; - detail::cf::vformat_to(range(buffer), cf, + detail::buffer& base = buffer; + detail::cf::vformat_to(std::back_inserter(base), cf, make_format_args(args...)); return to_string(buffer); } @@ -571,9 +571,8 @@ template ; using context = format_context_t; - return detail::cf::vformat_to(range(out), cf, + return detail::cf::vformat_to(out, cf, make_format_args(args...)); } diff --git a/include/fmt/format.h b/include/fmt/format.h index 3bb2b0d1..eb9895e9 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -587,7 +587,7 @@ void buffer::append(const U* begin, const U* end) { } } // namespace detail -// A range with an iterator appending to a buffer. +// DEPRECATED! A range with an iterator appending to a buffer. template class buffer_range : public detail::output_range>,