summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2024-06-08 12:17:46 +0200
committerStanislaw Halik <sthalik@misaki.pl>2024-06-08 12:17:46 +0200
commit461481e6bb8149c07121eb85a984e6393fa2b80d (patch)
tree7854a3e7415bf03f3f3f3333ce36451e697807a6 /src
parent53d61d8c52773fc10345282b499d2a45740fcaa8 (diff)
add hash() member function to global_coords
Diffstat (limited to 'src')
-rw-r--r--src/global-coords.cpp7
-rw-r--r--src/global-coords.hpp2
2 files changed, 9 insertions, 0 deletions
diff --git a/src/global-coords.cpp b/src/global-coords.cpp
index 4f3797f2..549a49ae 100644
--- a/src/global-coords.cpp
+++ b/src/global-coords.cpp
@@ -1,5 +1,6 @@
#include "global-coords.hpp"
#include "point.inl"
+#include "compat/hash.hpp"
#include <array>
#include <algorithm>
@@ -32,6 +33,12 @@ Debug& operator<<(Debug& dbg, const chunk_coords_& c)
return dbg;
}
+size_t global_coords::hash() const noexcept
+{
+ static_assert(sizeof *this == 4 + 4);
+ return hash_buf(this, sizeof *this);
+}
+
namespace {
static_assert(sizeof(decltype(local_coords::x))*8 == 8);
diff --git a/src/global-coords.hpp b/src/global-coords.hpp
index 031b84d7..67547f4d 100644
--- a/src/global-coords.hpp
+++ b/src/global-coords.hpp
@@ -138,6 +138,8 @@ public:
constexpr global_coords& operator+=(Vector2i vec) noexcept;
constexpr global_coords& operator-=(Vector2i vec) noexcept;
constexpr Vector2i operator-(global_coords other) const noexcept;
+
+ size_t hash() const noexcept;
};
constexpr local_coords global_coords::local() const noexcept