SPARK  0.1.0
A general purpose game engine written in C++.
Loading...
Searching...
No Matches
Vector2.h
1#pragma once
2
3namespace spark::math
4{
5 template <typename T>
7 : details::Vector<Vector2, T, 2>({std::ref(x), std::ref(y)}) {}
8
9 template <typename T>
10 constexpr Vector2<T>::Vector2(T x_value, T y_value) noexcept
11 : details::Vector<Vector2, T, 2>({std::ref(x), std::ref(y)}), x(x_value), y(y_value) {}
12
13 template <typename T>
14 constexpr Vector2<T>::Vector2(const Vector2& other)
15 : details::Vector<Vector2, T, 2>({std::ref(x), std::ref(y)}), x(other.x), y(other.y) {}
17 template <typename T>
18 constexpr Vector2<T>::Vector2(Vector2&& other) noexcept
19 : details::Vector<Vector2, T, 2>({std::ref(x), std::ref(y)}), x(std::move(other.x)), y(std::move(other.y)) {}
20
21 template <typename T>
22 constexpr Vector2<T>& Vector2<T>::operator=(const Vector2& other)
23 {
24 if (this == &other)
25 return *this;
26
27 x = other.x;
28 y = other.y;
29 return *this;
30 }
31
32 template <typename T>
33 constexpr Vector2<T>& Vector2<T>::operator=(Vector2&& other) noexcept
34 {
35 if (this == &other)
36 return *this;
38 x = std::move(other.x);
39 y = std::move(other.y);
40 return *this;
41 }
42
43 template <typename T>
44 template <typename To>
45 constexpr Vector2<To> Vector2<T>::castTo() const noexcept
46 {
47 return Vector2<To>(static_cast<To>(x), static_cast<To>(y));
48 }
49}
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