summaryrefslogtreecommitdiff
path: root/src/value.hh
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2014-12-16 18:57:19 +0000
committerMaxime Coste <frrrwww@gmail.com>2014-12-16 18:57:19 +0000
commitebecd60eb810246cfa682a1fbd72270aa9861f0b (patch)
tree0c5c707b68cb08fc93ace2433291deb8a52db5bc /src/value.hh
parentdbd7bd41bbf39d1fd5736997122a4652c78ddc50 (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/value.hh')
-rw-r--r--src/value.hh23
1 files changed, 5 insertions, 18 deletions
diff --git a/src/value.hh b/src/value.hh
index 86bbfea2..e663513a 100644
--- a/src/value.hh
+++ b/src/value.hh
@@ -1,11 +1,11 @@
#ifndef value_hh_INCLUDED
#define value_hh_INCLUDED
-#include <memory>
-#include <unordered_map>
-
+#include "unordered_map.hh"
#include "units.hh"
+#include <memory>
+
namespace Kakoune
{
@@ -76,23 +76,10 @@ struct ValueId : public StronglyTypedNumber<ValueId, int>
}
};
-using ValueMap = std::unordered_map<ValueId, Value>;
+inline size_t hash_value(ValueId val) { return hash_value((int)val); }
-}
-
-namespace std
-{
-
-template<>
-struct hash<Kakoune::ValueId>
-{
- size_t operator()(Kakoune::ValueId val) const
- {
- return std::hash<int>()((int)val);
- }
-};
+using ValueMap = UnorderedMap<ValueId, Value>;
}
-
#endif // value_hh_INCLUDED