diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2014-12-16 18:57:19 +0000 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2014-12-16 18:57:19 +0000 |
| commit | ebecd60eb810246cfa682a1fbd72270aa9861f0b (patch) | |
| tree | 0c5c707b68cb08fc93ace2433291deb8a52db5bc /src/keys.hh | |
| parent | dbd7bd41bbf39d1fd5736997122a4652c78ddc50 (diff) | |
Rework hashing, use a more extensible framework similar to n3876 proposal
std::hash specialization is a pain to work with, stop using that, and
just specialize a 'size_t hash_value(const T&)' free function.
Diffstat (limited to 'src/keys.hh')
| -rw-r--r-- | src/keys.hh | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/src/keys.hh b/src/keys.hh index 3123f7cc..92ae0f70 100644 --- a/src/keys.hh +++ b/src/keys.hh @@ -3,6 +3,7 @@ #include "unicode.hh" #include "flags.hh" +#include "hash.hh" #include <vector> @@ -11,7 +12,7 @@ namespace Kakoune struct Key { - enum class Modifiers + enum class Modifiers : int { None = 0, Control = 1 << 0, @@ -78,21 +79,8 @@ constexpr Key alt(Codepoint key) { return { Key::Modifiers::Alt, key }; } constexpr Key ctrl(Codepoint key) { return { Key::Modifiers::Control, key }; } constexpr Key ctrlalt(Codepoint key) { return { Key::Modifiers::ControlAlt, key }; } -} - -namespace std -{ - -template<> -struct hash<Kakoune::Key> -{ - size_t operator()(Kakoune::Key key) const - { - return static_cast<size_t>(key.modifiers) * 1024 + key.key; - } -}; +inline size_t hash_value(const Key& key) { return hash_values(key.modifiers, key.key); } } - #endif // keys_hh_INCLUDED |
