aboutsummaryrefslogtreecommitdiff
path: root/src/engine/data
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2022-06-02 19:51:54 +0200
committerHampusM <hampus@hampusmat.com>2022-06-13 17:57:00 +0200
commiteecf4b1e666211a13afa56f93477c55e8fd01621 (patch)
tree410510d6e058995174d5a5b0f535fb457a0c3542 /src/engine/data
parent87f55120f96d0f4f80b497dc9006d89df2dda125 (diff)
feat: implement game of lifev0.1.0
Diffstat (limited to 'src/engine/data')
-rw-r--r--src/engine/data/vector2.cpp7
-rw-r--r--src/engine/data/vector2.hpp2
2 files changed, 9 insertions, 0 deletions
diff --git a/src/engine/data/vector2.cpp b/src/engine/data/vector2.cpp
index 0f203d0..cb81947 100644
--- a/src/engine/data/vector2.cpp
+++ b/src/engine/data/vector2.cpp
@@ -2,6 +2,8 @@
#include "util/hash.hpp"
+#include <tuple>
+
auto Vector2::get_x() const noexcept -> Vector2::Value
{
return _x;
@@ -79,6 +81,11 @@ auto Vector2::operator==(const Vector2 &rhs) const noexcept -> bool
return _x == rhs._x && _y == rhs._y;
}
+auto Vector2::operator<(const Vector2 &rhs) const noexcept -> bool
+{
+ return std::tie(_x, _y) < std::tie(rhs._x, rhs._y);
+}
+
auto Vector2Hasher::operator()(const Vector2 &vector2) const noexcept -> std::size_t
{
std::size_t result_hash = 0;
diff --git a/src/engine/data/vector2.hpp b/src/engine/data/vector2.hpp
index 620b41c..96ebf87 100644
--- a/src/engine/data/vector2.hpp
+++ b/src/engine/data/vector2.hpp
@@ -43,6 +43,8 @@ public:
auto operator==(const Vector2 &rhs) const noexcept -> bool;
+ auto operator<(const Vector2 &rhs) const noexcept -> bool;
+
/**
* Returns Vector2({.x = 0, .y = 1})
*/