Skip to content

Commit

Permalink
Added missing typename to FMT_STRING. (#1089)
Browse files Browse the repository at this point in the history
* Added missing typename to FMT_STRING.

This is so that FMT_STRING can be used in a template.
  • Loading branch information
mwinterb authored and vitaut committed Mar 21, 2019
1 parent f0b572d commit 7ad3015
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion include/fmt/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -3619,7 +3619,8 @@ FMT_END_NAMESPACE
} \
} result; \
/* Suppress Qt Creator warning about unused operator. */ \
(void)static_cast<fmt::basic_string_view<str::char_type>>(result); \
(void)static_cast<fmt::basic_string_view<typename str::char_type>>( \
result); \
return result; \
}()

Expand Down
9 changes: 9 additions & 0 deletions test/format-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2475,6 +2475,15 @@ TEST(FormatTest, VFormatTo) {
EXPECT_EQ(L"42", w);
}

template <typename T> 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) {
Expand Down

0 comments on commit 7ad3015

Please sign in to comment.