Orderable Keys

This commit is contained in:
Maxime Coste 2015-03-07 15:29:21 +00:00
parent 4be6090107
commit 3ece7bcf75

View File

@ -57,11 +57,11 @@ struct Key
constexpr Key(Codepoint key) constexpr Key(Codepoint key)
: modifiers(Modifiers::None), key(key) {} : modifiers(Modifiers::None), key(key) {}
constexpr bool operator==(Key other) const constexpr uint64_t val() const { return (uint64_t)modifiers << 32 | key; }
{ return modifiers == other.modifiers and key == other.key; }
constexpr bool operator!=(Key other) const constexpr bool operator==(Key other) const { return val() == other.val(); }
{ return modifiers != other.modifiers or key != other.key; } constexpr bool operator!=(Key other) const { return val() != other.val(); }
constexpr bool operator<(Key other) const { return val() < other.val(); }
}; };
template<> struct WithBitOps<Key::Modifiers> : std::true_type {}; template<> struct WithBitOps<Key::Modifiers> : std::true_type {};