SPARK  0.1.0
A general purpose game engine written in C++.
Loading...
Searching...
No Matches
Vector4.h
1#pragma once
2
3namespace spark::math
4{
5 template <typename T>
7 : details::Vector<Vector4, T, 4>({std::ref(x), std::ref(y), std::ref(z), std::ref(w)}) {}
8
9 template <typename T>
10 constexpr Vector4<T>::Vector4(T value_x, T value_y, T value_z, T value_w) noexcept
11 : details::Vector<Vector4, T, 4>({std::ref(x), std::ref(y), std::ref(z), std::ref(w)}),
12 x(std::move(value_x)), y(std::move(value_y)), z(std::move(value_z)), w(std::move(value_w)) {}
13
14 template <typename T>
15 constexpr Vector4<T>::Vector4(const Vector4& other)
16 : details::Vector<Vector4, T, 4>({std::ref(x), std::ref(y), std::ref(z), std::ref(w)}), x(other.x), y(other.y),
17 z(other.z), w(other.w) {}
18
19 template <typename T>
20 constexpr Vector4<T>::Vector4(Vector4&& other) noexcept
21 : details::Vector<Vector4, T, 4>({std::ref(x), std::ref(y), std::ref(z), std::ref(w)}), x(std::move(other.x)),
22 y(std::move(other.y)), z(std::move(other.z)), w(std::move(other.w)) {}
23
24 template <typename T>
25 constexpr Vector4<T>& Vector4<T>::operator=(const Vector4& other)
26 {
27 if (this == &other)
28 return *this;
29
30 x = other.x;
31 y = other.y;
32 z = other.z;
33 w = other.w;
34 return *this;
35 }
36
37 template <typename T>
38 constexpr Vector4<T>& Vector4<T>::operator=(Vector4&& other) noexcept
39 {
40 if (this == &other)
41 return *this;
42
43 x = std::move(other.x);
44 y = std::move(other.y);
45 z = std::move(other.z);
46 w = std::move(other.w);
47 return *this;
48 }
49
50 template <typename T>
51 template <typename To>
52 constexpr Vector4<To> Vector4<T>::castTo() const noexcept
53 {
54 return Vector4<To>(static_cast<To>(x), static_cast<To>(y), static_cast<To>(z), static_cast<To>(w));
55 }
56}
A vector with four components.
Definition Vector4.h:13
constexpr Vector4()
Initializes a new Vector4 with all components to their default value.
Definition Vector4.h:6
constexpr Vector4< To > castTo() const noexcept
Casts all components of the Vector4 to the type To.
Definition Vector4.h:52
Definition Vector.h:12