Enable format_as for non-integral types

This commit is contained in:
Victor Zverovich
2023-01-02 10:43:08 -08:00
parent 09ed1ddb9c
commit b7535365b2
2 changed files with 5 additions and 1 deletions

View File

@@ -677,6 +677,9 @@ namespace test {
enum class scoped_enum_as_int {};
auto format_as(scoped_enum_as_int) -> int { return 42; }
enum class scoped_enum_as_string {};
auto format_as(scoped_enum_as_string) -> fmt::string_view { return "foo"; }
struct convertible_to_enum {
operator scoped_enum_as_int() const { return {}; }
};
@@ -734,6 +737,7 @@ TEST(core_test, format_to) {
TEST(core_test, format_as) {
EXPECT_EQ(fmt::format("{}", test::scoped_enum_as_int()), "42");
EXPECT_EQ(fmt::format("{}", test::scoped_enum_as_string()), "foo");
}
#ifdef __cpp_lib_byte