From 3273ef1e3f5621d2dc226ea8ca6907fe5ddacd0a Mon Sep 17 00:00:00 2001 From: Hendiadyoin1 Date: Mon, 11 Sep 2023 15:07:03 +0200 Subject: [PATCH] AK: Add helper to make DistinctNumeric types comparable to enums --- AK/DistinctNumeric.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/AK/DistinctNumeric.h b/AK/DistinctNumeric.h index 9d3bc3b4bc3..82f63dd3464 100644 --- a/AK/DistinctNumeric.h +++ b/AK/DistinctNumeric.h @@ -322,6 +322,9 @@ struct Formatter> : Formatter { #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 struct Traits> : public GenericTraits> { static constexpr bool is_trivial() { return true; }