diff --git a/include/fmt/format.h b/include/fmt/format.h index 8ee403e8..6a9d8bc6 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -3904,13 +3904,14 @@ constexpr auto format_as(Enum e) noexcept -> underlying_t { } // namespace enums #ifdef __cpp_lib_byte -template <> struct formatter : formatter { +template +struct formatter : formatter { static auto format_as(std::byte b) -> unsigned char { return static_cast(b); } template auto format(std::byte b, Context& ctx) const -> decltype(ctx.out()) { - return formatter::format(format_as(b), ctx); + return formatter::format(format_as(b), ctx); } }; #endif diff --git a/test/xchar-test.cc b/test/xchar-test.cc index 44b19e87..a94c1bd2 100644 --- a/test/xchar-test.cc +++ b/test/xchar-test.cc @@ -171,6 +171,13 @@ TEST(xchar_test, join) { EXPECT_EQ(fmt::format(L"({})", fmt::join(t, L", ")), L"(a, 1, 2)"); } +#ifdef __cpp_lib_byte +TEST(xchar_test, join_bytes) { + auto v = std::vector{std::byte(1), std::byte(2), std::byte(3)}; + EXPECT_EQ(fmt::format(L"{}", fmt::join(v, L", ")), L"1, 2, 3"); +} +#endif + enum streamable_enum {}; std::wostream& operator<<(std::wostream& os, streamable_enum) {