From 7ad3015f5bc77eda28d52f820e6d89955bf0784a Mon Sep 17 00:00:00 2001 From: mwinterb Date: Wed, 20 Mar 2019 20:37:00 -0700 Subject: [PATCH] Added missing typename to FMT_STRING. (#1089) * Added missing typename to FMT_STRING. This is so that FMT_STRING can be used in a template. --- include/fmt/format.h | 3 ++- test/format-test.cc | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/include/fmt/format.h b/include/fmt/format.h index bbc6fb42a791..0a251ce0cdfd 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -3619,7 +3619,8 @@ FMT_END_NAMESPACE } \ } result; \ /* Suppress Qt Creator warning about unused operator. */ \ - (void)static_cast>(result); \ + (void)static_cast>( \ + result); \ return result; \ }() diff --git a/test/format-test.cc b/test/format-test.cc index 2e0ff199a8d2..1b5a2f7120a5 100644 --- a/test/format-test.cc +++ b/test/format-test.cc @@ -2475,6 +2475,15 @@ TEST(FormatTest, VFormatTo) { EXPECT_EQ(L"42", w); } +template static std::string FmtToString(const T& t) { + return fmt::format(FMT_STRING("{}"), t); +} + +TEST(FormatTest, FmtStringInTemplate) { + EXPECT_EQ(FmtToString(1), "1"); + EXPECT_EQ(FmtToString(0), "0"); +} + #endif // FMT_USE_CONSTEXPR TEST(FormatTest, ConstructU8StringViewFromCString) {