mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 19:57:45 +00:00
AK: Add helper to make DistinctNumeric types comparable to enums
This commit is contained in:
parent
1b2007cc7f
commit
3273ef1e3f
1 changed files with 3 additions and 0 deletions
|
@ -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)
|
#define AK_TYPEDEF_DISTINCT_ORDERED_ID(T, NAME) AK_TYPEDEF_DISTINCT_NUMERIC_GENERAL(T, NAME, Comparison, CastToBool)
|
||||||
// TODO: Further type aliases?
|
// 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>
|
template<typename T, typename X, typename... Opts>
|
||||||
struct Traits<AK::DistinctNumeric<T, X, Opts...>> : public GenericTraits<AK::DistinctNumeric<T, X, Opts...>> {
|
struct Traits<AK::DistinctNumeric<T, X, Opts...>> : public GenericTraits<AK::DistinctNumeric<T, X, Opts...>> {
|
||||||
static constexpr bool is_trivial() { return true; }
|
static constexpr bool is_trivial() { return true; }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue