diff options
author | HampusM <hampus@hampusmat.com> | 2022-07-01 16:01:04 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2022-07-01 16:01:04 +0200 |
commit | 7307815e99a79dac42f2a9c06b0fe6171ea11ba0 (patch) | |
tree | ad41ee819dc87fc2653caf720fa7d1df30c0caeb /src/engine/data/vector2.cpp | |
parent | 2bff8c999edde11270ecaf6fbd2d24f54d0e360b (diff) |
refactor: use ranges
Diffstat (limited to 'src/engine/data/vector2.cpp')
-rw-r--r-- | src/engine/data/vector2.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/engine/data/vector2.cpp b/src/engine/data/vector2.cpp index 84986bd..80fc43c 100644 --- a/src/engine/data/vector2.cpp +++ b/src/engine/data/vector2.cpp @@ -82,11 +82,31 @@ 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 !(*this == rhs); +} + auto Vector2::operator<(const Vector2 &rhs) const noexcept -> bool { return std::tie(_x, _y) < std::tie(rhs._x, rhs._y); } +auto Vector2::operator>(const Vector2 &rhs) const noexcept -> bool +{ + return std::tie(_x, _y) > std::tie(rhs._x, rhs._y); +} + +auto Vector2::operator<=(const Vector2 &rhs) const noexcept -> bool +{ + return *this < rhs || *this == rhs; +} + +auto Vector2::operator>=(const Vector2 &rhs) const noexcept -> bool +{ + return *this > rhs || *this == rhs; +} + auto Vector2Hasher::operator()(const Vector2 &vector2) const noexcept -> std::size_t { std::size_t result_hash = 0; |