diff --git a/include/fmt/core.h b/include/fmt/core.h index 90fcef56..94d97859 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -1539,7 +1539,7 @@ FMT_CONSTEXPR FMT_INLINE auto make_arg(const T& val) -> value { !std::is_same::value, "Cannot format an argument. To make type T formattable provide a " "formatter specialization: https://fmt.dev/latest/api.html#udt"); - return arg; + return {arg}; } template operator T() const { return T(); } +}; + +FMT_BEGIN_NAMESPACE +template <> struct formatter { + FMT_CONSTEXPR auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) { + return ctx.begin(); + } + + auto format(converible_to_anything, format_context& ctx) + -> decltype(ctx.out()) { + return format_to(ctx.out(), "foo"); + } +}; +FMT_END_NAMESPACE + +TEST(format_test, format_convertible_to_anything) { + EXPECT_EQ("foo", fmt::format("{}", converible_to_anything())); +} + class Answer {}; FMT_BEGIN_NAMESPACE