diff --git a/include/fmt/compile.h b/include/fmt/compile.h index d486a867..0c37adc4 100644 --- a/include/fmt/compile.h +++ b/include/fmt/compile.h @@ -468,12 +468,8 @@ constexpr auto compile_format_string(S format_str) { return parse_tail(make_text(str, POS, 1), format_str); } else if constexpr (str[POS + 1] == '}') { using type = get_type; - if constexpr (std::is_same::value) { - return parse_tail(field(), - format_str); - } else { - return unknown_format(); - } + return parse_tail(field(), + format_str); } else { return unknown_format(); } @@ -565,7 +561,7 @@ FMT_INLINE std::basic_string format(S, Args&&... args) { if (str.size() == 2 && str[0] == '{' && str[1] == '}') return fmt::to_string(detail::first(args...)); constexpr auto compiled = compile(S()); - return format(compiled, std::forward(args...)); + return format(compiled, std::forward(args)...); } template (""); EXPECT_EQ(fmt::format(f), ""); } + +#ifdef __cpp_if_constexpr +TEST(CompileTest, Basic) { + EXPECT_EQ("42", fmt::format(FMT_COMPILE("{}"), 42)); + EXPECT_EQ("foo", fmt::format(FMT_COMPILE("{}"), "foo")); +} +#endif