From 2a9e8b52de74661795650b2fb0fc056c9111d334 Mon Sep 17 00:00:00 2001 From: denchat <19730041+denchat@users.noreply.github.com> Date: Tue, 14 May 2019 22:41:11 +0700 Subject: [PATCH] Fix advance_to() and begin() using iterator (#1159) --- include/format | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/format b/include/format index 66a1e440..8c0bef75 100644 --- a/include/format +++ b/include/format @@ -608,16 +608,16 @@ struct format_handler : detail::error_handler { void on_arg_id(fmt::basic_string_view) {} void on_replacement_field(const Char* p) { - parse_ctx.advance_to(p); + parse_ctx.advance_to(parse_ctx.begin() + (p - &*parse_ctx.begin())); custom_formatter f(parse_ctx, context); if (!visit_format_arg(f, arg)) context.advance_to(visit_format_arg(ArgFormatter(context, &parse_ctx), arg)); } const Char* on_format_specs(const Char* begin, const Char* end) { - parse_ctx.advance_to(begin); + parse_ctx.advance_to(parse_ctx.begin() + (begin - &*parse_ctx.begin())); custom_formatter f(parse_ctx, context); - if (visit_format_arg(f, arg)) return parse_ctx.begin(); + if (visit_format_arg(f, arg)) return &*parse_ctx.begin(); fmt::basic_format_specs specs; using fmt::internal::specs_handler; using parse_context = basic_format_parse_context; @@ -625,7 +625,7 @@ struct format_handler : detail::error_handler { specs_handler(specs, parse_ctx, context), get_type(arg)); begin = parse_format_specs(begin, end, handler); if (begin == end || *begin != '}') on_error("missing '}' in format string"); - parse_ctx.advance_to(begin); + parse_ctx.advance_to(parse_ctx.begin() + (begin - &*parse_ctx.begin())); context.advance_to(visit_format_arg(ArgFormatter(context, &parse_ctx, &specs), arg)); return begin; }