Compatibility with fmtlib 10.1.x

This commit is contained in:
Exzap 2023-10-02 18:52:54 +02:00
parent ff9d180154
commit 757d458161
8 changed files with 39 additions and 38 deletions

View file

@ -552,6 +552,29 @@ inline uint32 GetTitleIdLow(uint64 titleId)
#include "Cafe/HW/Espresso/PPCState.h"
#include "Cafe/HW/Espresso/PPCCallback.h"
// generic formatter for enums (to underlying)
template <typename Enum>
requires std::is_enum_v<Enum>
struct fmt::formatter<Enum> : fmt::formatter<underlying_t<Enum>>
{
auto format(const Enum& e, format_context& ctx) const
{
//return fmt::format_to(ctx.out(), "{}", fmt::underlying(e));
return formatter<underlying_t<Enum>>::format(fmt::underlying(e), ctx);
}
};
// formatter for betype<T>
template <typename T>
struct fmt::formatter<betype<T>> : fmt::formatter<T>
{
auto format(const betype<T>& e, format_context& ctx) const
{
return formatter<T>::format(static_cast<T>(e), ctx);
}
};
// useful C++23 stuff that isn't yet widely supported
// std::to_underlying
@ -561,5 +584,4 @@ namespace stdx
constexpr std::underlying_type_t<EnumT> to_underlying(EnumT e) noexcept {
return static_cast<std::underlying_type_t<EnumT>>(e);
};
}
}