From a7e986166a271029217b06245e6529b2ec714694 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Sun, 29 Oct 2017 08:19:55 -0700 Subject: [PATCH] Workaround another MSVC madness --- include/fmt/format.h | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/include/fmt/format.h b/include/fmt/format.h index 07e96132..98f1f249 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -3518,6 +3518,23 @@ constexpr Iterator parse_format_specs(Iterator it, SpecHandler &handler) { return it; } +template +struct id_adapter { + constexpr explicit id_adapter(Handler &h): handler(h) {} + + constexpr void operator()() { handler.on_arg_id(); } + constexpr void operator()(unsigned id) { handler.on_arg_id(id); } + constexpr void operator()(basic_string_view id) { + handler.on_arg_id(id); + } + + constexpr void on_error(const char *message) { + handler.on_error(message); + } + + Handler &handler; +}; + template constexpr void parse_format_string(Iterator it, Handler &handler) { using char_type = typename std::iterator_traits::value_type; @@ -3536,23 +3553,7 @@ constexpr void parse_format_string(Iterator it, Handler &handler) { } handler.on_text(start, it - 1); - struct id_adapter { - constexpr explicit id_adapter(Handler &h): handler(h) {} - - constexpr void operator()() { handler.on_arg_id(); } - constexpr void operator()(unsigned id) { handler.on_arg_id(id); } - constexpr void operator()(basic_string_view id) { - handler.on_arg_id(id); - } - - constexpr void on_error(const char *message) { - handler.on_error(message); - } - - Handler &handler; - } adapter(handler); - - it = parse_arg_id(it, adapter); + it = parse_arg_id(it, id_adapter(handler)); if (*it == '}') { handler.on_replacement_field(it); } else if (*it == ':') {