diff --git a/include/fmt/core.h b/include/fmt/core.h index ec729116..94b31f71 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -1525,6 +1525,11 @@ using wformat_context = buffer_context; #define FMT_BUFFER_CONTEXT(Char) \ basic_format_context, Char> +template +using is_formattable = bool_constant>().map(std::declval())), + detail::unformattable>::value>; + /** \rst An array of references to arguments. It can be implicitly converted into diff --git a/test/core-test.cc b/test/core-test.cc index 50b5f9b8..5da58a60 100644 --- a/test/core-test.cc +++ b/test/core-test.cc @@ -617,6 +617,12 @@ TEST(CoreTest, HasFormatter) { ""); } +TEST(CoreTest, IsFormattable) { + static_assert(fmt::is_formattable::value, ""); + static_assert(!fmt::is_formattable::value, ""); + static_assert(fmt::is_formattable::value, ""); +} + struct convertible_to_int { operator int() const { return 42; } };