summaryrefslogtreecommitdiff
path: root/src/coord.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/coord.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/coord.hh')
-rw-r--r--src/coord.hh16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/coord.hh b/src/coord.hh
index dbae5001..ed9347a5 100644
--- a/src/coord.hh
+++ b/src/coord.hh
@@ -2,6 +2,7 @@
#define coord_hh_INCLUDED
#include "units.hh"
+#include "hash.hh"
namespace Kakoune
{
@@ -92,6 +93,11 @@ struct ByteCoord : LineAndColumn<ByteCoord, LineCount, ByteCount>
: LineAndColumn(line, column) {}
};
+inline size_t hash_value(const ByteCoord& val)
+{
+ return hash_values(val.line, val.column);
+}
+
struct CharCoord : LineAndColumn<CharCoord, LineCount, CharCount>
{
[[gnu::always_inline]]
@@ -99,6 +105,11 @@ struct CharCoord : LineAndColumn<CharCoord, LineCount, CharCount>
: LineAndColumn(line, column) {}
};
+inline size_t hash_value(const CharCoord& val)
+{
+ return hash_values(val.line, val.column);
+}
+
struct ByteCoordAndTarget : ByteCoord
{
[[gnu::always_inline]]
@@ -112,6 +123,11 @@ struct ByteCoordAndTarget : ByteCoord
CharCount target;
};
+inline size_t hash_value(const ByteCoordAndTarget& val)
+{
+ return hash_values(val.line, val.column, val.target);
+}
+
}
#endif // coord_hh_INCLUDED