From bc61f6905838170b2ad45a39b9168a4b4b6f8a39 Mon Sep 17 00:00:00 2001 From: gabime Date: Tue, 26 May 2020 23:47:57 +0300 Subject: [PATCH] Bump fmt version to 6.2.1 --- include/spdlog/fmt/bundled/core.h | 25 +++++++++++++-------- include/spdlog/fmt/bundled/ostream.h | 33 +++++++++++++++++++++++----- include/spdlog/fmt/bundled/printf.h | 9 ++++++-- include/spdlog/version.h | 2 +- 4 files changed, 52 insertions(+), 17 deletions(-) diff --git a/include/spdlog/fmt/bundled/core.h b/include/spdlog/fmt/bundled/core.h index 6df2875a..0e0824f5 100644 --- a/include/spdlog/fmt/bundled/core.h +++ b/include/spdlog/fmt/bundled/core.h @@ -18,7 +18,7 @@ #include // The fmt library version in the form major * 10000 + minor * 100 + patch. -#define FMT_VERSION 60200 +#define FMT_VERSION 60201 #ifdef __has_feature # define FMT_HAS_FEATURE(x) __has_feature(x) @@ -830,7 +830,8 @@ template struct string_value { template struct custom_value { using parse_context = basic_format_parse_context; const void* value; - void (*format)(const void* arg, parse_context& parse_ctx, Context& ctx); + void (*format)(const void* arg, + typename Context::parse_context_type& parse_ctx, Context& ctx); }; // A formatting argument value. @@ -890,9 +891,9 @@ template class value { private: // Formats an argument of a custom type, such as a user-defined class. template - static void format_custom_arg( - const void* arg, basic_format_parse_context& parse_ctx, - Context& ctx) { + static void format_custom_arg(const void* arg, + typename Context::parse_context_type& parse_ctx, + Context& ctx) { Formatter f; parse_ctx.advance_to(f.parse(parse_ctx)); ctx.advance_to(f.format(*static_cast(arg), ctx)); @@ -1061,7 +1062,7 @@ template class basic_format_arg { public: explicit handle(internal::custom_value custom) : custom_(custom) {} - void format(basic_format_parse_context& parse_ctx, + void format(typename Context::parse_context_type& parse_ctx, Context& ctx) const { custom_.format(custom_.value, parse_ctx, ctx); } @@ -1207,13 +1208,16 @@ FMT_CONSTEXPR basic_format_arg make_arg(const T& value) { return arg; } -template inline value make_arg(const T& val) { return arg_mapper().map(val); } -template inline basic_format_arg make_arg(const T& value) { return make_arg(value); @@ -1272,6 +1276,7 @@ template class basic_format_context { public: using iterator = OutputIt; using format_arg = basic_format_arg; + using parse_context_type = basic_format_parse_context; template using formatter_type = formatter; basic_format_context(const basic_format_context&) = delete; @@ -1346,7 +1351,9 @@ class format_arg_store #if FMT_GCC_VERSION && FMT_GCC_VERSION < 409 basic_format_args(*this), #endif - data_{internal::make_arg(args)...} { + data_{internal::make_arg< + is_packed, Context, + internal::mapped_type_constant::value>(args)...} { } }; diff --git a/include/spdlog/fmt/bundled/ostream.h b/include/spdlog/fmt/bundled/ostream.h index c4831533..4526f523 100644 --- a/include/spdlog/fmt/bundled/ostream.h +++ b/include/spdlog/fmt/bundled/ostream.h @@ -9,9 +9,14 @@ #define FMT_OSTREAM_H_ #include + #include "format.h" FMT_BEGIN_NAMESPACE + +template class basic_printf_parse_context; +template class basic_printf_context; + namespace internal { template class formatbuf : public std::basic_streambuf { @@ -93,9 +98,9 @@ void format_value(buffer& buf, const T& value, locale_ref loc = locale_ref()) { formatbuf format_buf(buf); std::basic_ostream output(&format_buf); - #if !defined(FMT_STATIC_THOUSANDS_SEPARATOR) +#if !defined(FMT_STATIC_THOUSANDS_SEPARATOR) if (loc) output.imbue(loc.get()); - #endif +#endif output.exceptions(std::ios_base::failbit | std::ios_base::badbit); output << value; buf.resize(buf.size()); @@ -104,14 +109,32 @@ void format_value(buffer& buf, const T& value, // Formats an object of type T that has an overloaded ostream operator<<. template struct fallback_formatter::value>> - : formatter, Char> { - template - auto format(const T& value, Context& ctx) -> decltype(ctx.out()) { + : private formatter, Char> { + auto parse(basic_format_parse_context& ctx) -> decltype(ctx.begin()) { + return formatter, Char>::parse(ctx); + } + template >::value)> + auto parse(ParseCtx& ctx) -> decltype(ctx.begin()) { + return ctx.begin(); + } + + template + auto format(const T& value, basic_format_context& ctx) + -> OutputIt { basic_memory_buffer buffer; format_value(buffer, value, ctx.locale()); basic_string_view str(buffer.data(), buffer.size()); return formatter, Char>::format(str, ctx); } + template + auto format(const T& value, basic_printf_context& ctx) + -> OutputIt { + basic_memory_buffer buffer; + format_value(buffer, value, ctx.locale()); + return std::copy(buffer.begin(), buffer.end(), ctx.out()); + } }; } // namespace internal diff --git a/include/spdlog/fmt/bundled/printf.h b/include/spdlog/fmt/bundled/printf.h index a7902280..5e0c4810 100644 --- a/include/spdlog/fmt/bundled/printf.h +++ b/include/spdlog/fmt/bundled/printf.h @@ -189,6 +189,10 @@ using internal::printf; // For printing into memory_buffer. template class printf_arg_formatter; +template +class basic_printf_parse_context : public basic_format_parse_context { + using basic_format_parse_context::basic_format_parse_context; +}; template class basic_printf_context; /** @@ -324,6 +328,7 @@ template class basic_printf_context { using char_type = Char; using iterator = OutputIt; using format_arg = basic_format_arg; + using parse_context_type = basic_printf_parse_context; template using formatter_type = printf_formatter; private: @@ -331,7 +336,7 @@ template class basic_printf_context { OutputIt out_; basic_format_args args_; - basic_format_parse_context parse_ctx_; + parse_context_type parse_ctx_; static void parse_flags(format_specs& specs, const Char*& it, const Char* end); @@ -362,7 +367,7 @@ template class basic_printf_context { format_arg arg(int id) const { return args_.get(id); } - basic_format_parse_context& parse_context() { return parse_ctx_; } + parse_context_type& parse_context() { return parse_ctx_; } FMT_CONSTEXPR void on_error(const char* message) { parse_ctx_.on_error(message); diff --git a/include/spdlog/version.h b/include/spdlog/version.h index f6d8224e..66c18296 100644 --- a/include/spdlog/version.h +++ b/include/spdlog/version.h @@ -5,6 +5,6 @@ #define SPDLOG_VER_MAJOR 1 #define SPDLOG_VER_MINOR 6 -#define SPDLOG_VER_PATCH 0 +#define SPDLOG_VER_PATCH 1 #define SPDLOG_VERSION (SPDLOG_VER_MAJOR * 10000 + SPDLOG_VER_MINOR * 100 + SPDLOG_VER_PATCH)