mirror of
https://github.com/fmtlib/fmt.git
synced 2025-07-29 18:27:40 +02:00
Add member format_as for std
This commit is contained in:
@ -42,6 +42,7 @@
|
||||
|
||||
#ifndef FMT_MODULE
|
||||
# include <cmath> // std::signbit
|
||||
# include <cstddef> // std::byte
|
||||
# include <cstdint> // uint32_t
|
||||
# include <cstring> // std::memcpy
|
||||
# include <initializer_list> // std::initializer_list
|
||||
@ -3919,6 +3920,18 @@ constexpr auto format_as(Enum e) noexcept -> underlying_t<Enum> {
|
||||
}
|
||||
} // namespace enums
|
||||
|
||||
#ifdef __cpp_lib_byte
|
||||
template <> struct formatter<std::byte> : formatter<unsigned> {
|
||||
static auto format_as(std::byte b) -> unsigned char {
|
||||
return static_cast<unsigned char>(b);
|
||||
}
|
||||
template <typename Context>
|
||||
auto format(std::byte b, Context& ctx) const -> decltype(ctx.out()) {
|
||||
return formatter<unsigned>::format(format_as(b), ctx);
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
class bytes {
|
||||
private:
|
||||
string_view data_;
|
||||
|
Reference in New Issue
Block a user