Make FMT_COMPILE fallback on runtime without if constexpr (#2261)

This commit is contained in:
Victor Zverovich
2021-04-28 09:11:47 -07:00
parent 0cd0fb9184
commit 355be4b13f
2 changed files with 11 additions and 1 deletions

View File

@ -155,6 +155,12 @@ TEST(CompileTest, EmptyFormatString) {
EXPECT_EQ(fmt::format(f), "");
}
TEST(CompileTest, CompileFallback) {
// FMT_COMPILE should fallback on runtime formatting when `if constexpr` is
// not available.
EXPECT_EQ("42", fmt::format(FMT_COMPILE("{}"), 42));
}
#ifdef __cpp_if_constexpr
TEST(CompileTest, FormatDefault) {
EXPECT_EQ("42", fmt::format(FMT_COMPILE("{}"), 42));