diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2015-03-07 15:29:21 +0000 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2015-03-07 15:29:21 +0000 |
| commit | 3ece7bcf75d3cb7e2dad50497c11d1069f486c0e (patch) | |
| tree | cb8a021b240efea19def1cacf97401fa462991ed /src/keys.hh | |
| parent | 4be609010758f0daef1be567a2b2bbea20700e1e (diff) | |
Orderable Keys
Diffstat (limited to 'src/keys.hh')
| -rw-r--r-- | src/keys.hh | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/keys.hh b/src/keys.hh index f754ce68..c83e1361 100644 --- a/src/keys.hh +++ b/src/keys.hh @@ -57,11 +57,11 @@ struct Key constexpr Key(Codepoint key) : modifiers(Modifiers::None), key(key) {} - constexpr bool operator==(Key other) const - { return modifiers == other.modifiers and key == other.key; } + constexpr uint64_t val() const { return (uint64_t)modifiers << 32 | key; } - constexpr bool operator!=(Key other) const - { 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(); } + constexpr bool operator<(Key other) const { return val() < other.val(); } }; template<> struct WithBitOps<Key::Modifiers> : std::true_type {}; |
