Skip to content

Commit 9c21743

Browse files
committed
Fix std::byte formatting in 11.2
1 parent 40626af commit 9c21743

1 file changed

Lines changed: 16 additions & 9 deletions

File tree

include/fmt/format.h

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3850,15 +3850,15 @@ constexpr auto format_as(Enum e) noexcept -> underlying_t<Enum> {
38503850
} // namespace enums
38513851

38523852
#ifdef __cpp_lib_byte
3853-
template <> struct formatter<std::byte> : formatter<unsigned> {
3854-
static auto format_as(std::byte b) -> unsigned char {
3855-
return static_cast<unsigned char>(b);
3856-
}
3857-
template <typename Context>
3858-
auto format(std::byte b, Context& ctx) const -> decltype(ctx.out()) {
3859-
return formatter<unsigned>::format(format_as(b), ctx);
3860-
}
3861-
};
3853+
// template <> struct formatter<std::byte> : formatter<unsigned> {
3854+
// static auto format_as(std::byte b) -> unsigned char {
3855+
// return static_cast<unsigned char>(b);
3856+
// }
3857+
// template <typename Context>
3858+
// auto format(std::byte b, Context& ctx) const -> decltype(ctx.out()) {
3859+
// return formatter<unsigned>::format(format_as(b), ctx);
3860+
// }
3861+
// };
38623862
#endif
38633863

38643864
struct bytes {
@@ -4231,6 +4231,13 @@ FMT_NODISCARD auto to_string(const T& value) -> std::string {
42314231
FMT_END_EXPORT
42324232
FMT_END_NAMESPACE
42334233

4234+
namespace std {
4235+
template <typename T, FMT_ENABLE_IF(std::is_same<T, std::byte>::value)>
4236+
inline auto format_as(T b) -> unsigned char {
4237+
return static_cast<unsigned char>(b);
4238+
}
4239+
} // namespace std
4240+
42344241
#ifdef FMT_HEADER_ONLY
42354242
# define FMT_FUNC inline
42364243
# include "format-inl.h"

0 commit comments

Comments
 (0)