AK: Add helper to make DistinctNumeric types comparable to enums

This commit is contained in:
Hendiadyoin1 2023-09-11 15:07:03 +02:00 committed by Andrew Kaster
parent 1b2007cc7f
commit 3273ef1e3f
Notes: sideshowbarker 2024-07-17 07:19:27 +09:00

View File

@ -322,6 +322,9 @@ struct Formatter<DistinctNumeric<T, X, Opts...>> : Formatter<T> {
#define AK_TYPEDEF_DISTINCT_ORDERED_ID(T, NAME) AK_TYPEDEF_DISTINCT_NUMERIC_GENERAL(T, NAME, Comparison, CastToBool)
// TODO: Further type aliases?
#define AK_MAKE_DISTINCT_NUMERIC_COMPARABLE_TO_ENUM(DN, E) \
constexpr bool operator==(DN n, E e) { return n.value() == to_underlying(e); }
template<typename T, typename X, typename... Opts>
struct Traits<AK::DistinctNumeric<T, X, Opts...>> : public GenericTraits<AK::DistinctNumeric<T, X, Opts...>> {
static constexpr bool is_trivial() { return true; }