From dcd0ffcaece7f9ea3785d0ffca30a82cd60c573c Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Thu, 25 Jul 2019 16:31:54 -1000 Subject: [PATCH] Fix custom formatting of multiple character types --- fmt | 2 +- include/logvisor/logvisor.hpp | 13 +++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/fmt b/fmt index 6bcc3fd..25ff2ef 160000 --- a/fmt +++ b/fmt @@ -1 +1 @@ -Subproject commit 6bcc3fd21694b5634cc006915bd049cf460a9a8d +Subproject commit 25ff2efc0aeab3ce886fb6be11a1878f3497ec4c diff --git a/include/logvisor/logvisor.hpp b/include/logvisor/logvisor.hpp index ee22dd4..f396b2d 100644 --- a/include/logvisor/logvisor.hpp +++ b/include/logvisor/logvisor.hpp @@ -257,10 +257,7 @@ public: } }; -#define Lfmt(str) fmt(L##str) -#define ufmt(str) fmt(u##str) -#define Ufmt(str) fmt(U##str) -#define FMT_CUSTOM_FORMATTER(tp, ...) \ +#define FMT_CUSTOM_FORMATTER(tp, fmtstr, ...) \ namespace fmt { \ template <> \ struct formatter { \ @@ -268,7 +265,7 @@ struct formatter { \ constexpr auto parse(ParseContext &ctx) { return ctx.begin(); } \ template \ auto format(const tp &obj, FormatContext &ctx) { \ - return format_to(ctx.out(), __VA_ARGS__); \ + return format_to(ctx.out(), fmt(fmtstr), __VA_ARGS__); \ } \ }; \ template <> \ @@ -277,7 +274,7 @@ struct formatter { \ constexpr auto parse(ParseContext &ctx) { return ctx.begin(); } \ template \ auto format(const tp &obj, FormatContext &ctx) { \ - return format_to(ctx.out(), L##__VA_ARGS__); \ + return format_to(ctx.out(), fmt(L##fmtstr), __VA_ARGS__); \ } \ }; \ template <> \ @@ -286,7 +283,7 @@ struct formatter { \ constexpr auto parse(ParseContext &ctx) { return ctx.begin(); } \ template \ auto format(const tp &obj, FormatContext &ctx) { \ - return format_to(ctx.out(), u##__VA_ARGS__); \ + return format_to(ctx.out(), fmt(u##fmtstr), __VA_ARGS__); \ } \ }; \ template <> \ @@ -295,7 +292,7 @@ struct formatter { \ constexpr auto parse(ParseContext &ctx) { return ctx.begin(); } \ template \ auto format(const tp &obj, FormatContext &ctx) { \ - return format_to(ctx.out(), U##__VA_ARGS__); \ + return format_to(ctx.out(), fmt(U##fmtstr), __VA_ARGS__); \ } \ }; \ }