mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
AK: Add helper to make DistinctNumeric types comparable to enums
This commit is contained in:
parent
1b2007cc7f
commit
3273ef1e3f
Notes:
sideshowbarker
2024-07-17 07:19:27 +09:00
Author: https://github.com/Hendiadyoin1 Commit: https://github.com/SerenityOS/serenity/commit/3273ef1e3f Pull-request: https://github.com/SerenityOS/serenity/pull/21028 Reviewed-by: https://github.com/ADKaster ✅ Reviewed-by: https://github.com/supercomputer7 ✅
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…
Reference in a new issue