SPARK  0.1.0
A general purpose game engine written in C++.
Loading...
Searching...
No Matches
Vector2.h
1#pragma once
2
3#include "spark/math/details/Vector.h"
4
5namespace spark::math
6{
11 template <typename T>
12 class Vector2 final : public details::Vector<Vector2, T, 2>
13 {
14 public:
16 constexpr Vector2();
17
23 constexpr Vector2(T x_value, T y_value) noexcept;
24 ~Vector2() = default;
25
26 constexpr Vector2(const Vector2& other);
27 constexpr Vector2(Vector2&& other) noexcept;
28 constexpr Vector2& operator=(const Vector2& other);
29 constexpr Vector2& operator=(Vector2&& other) noexcept;
30
36 template <typename To>
37 [[nodiscard]] constexpr Vector2<To> castTo() const noexcept;
38
39 public:
40 T x {};
41 T y {};
42 };
43}
44
45#include "spark/math/impl/Vector2.h"
46
47template <typename T>
48struct std::hash<spark::math::Vector2<T>>
49{
50 std::size_t operator()(const spark::math::Vector2<T>& vec) const
51 {
52 return std::hash<T> {}(vec.x) ^ std::hash<T> {}(vec.y);
53 }
54};
A vector with two components.
Definition Vector2.h:13
constexpr Vector2< To > castTo() const noexcept
Casts all components of the Vector2 to the type To.
Definition Vector2.h:45
constexpr Vector2()
Initializes a new Vector2 with all components to their default value.
Definition Vector2.h:6
Definition Vector.h:12