summaryrefslogtreecommitdiff
path: root/src/Math
diff options
context:
space:
mode:
Diffstat (limited to 'src/Math')
-rw-r--r--src/Math/Vector.hpp29
1 files changed, 9 insertions, 20 deletions
diff --git a/src/Math/Vector.hpp b/src/Math/Vector.hpp
index ccfa556..260891d 100644
--- a/src/Math/Vector.hpp
+++ b/src/Math/Vector.hpp
@@ -2,17 +2,14 @@
#include <cstddef>
#include <sstream>
-#include <iostream>
-#include <iterator>
#include <cmath>
#include <functional>
template <size_t S, typename T = float>
struct Vector {
-public:
Vector(): elements{} {};
- template<typename ...Args, typename std::enable_if<sizeof...(Args) == S, int>::type = 0>
+ template<typename ...Args, std::enable_if_t<sizeof...(Args) == S, int> = 0>
Vector<S, T>(Args... args) : elements{ args... } {};
Vector<S, T>(T values[S]) {
@@ -117,25 +114,17 @@ public:
return map([=](auto x) { return x / scalar; });
}
- T x() const {
- static_assert(S > 0);
- return elements[0];
- }
+ T& x() { static_assert(S > 0); return elements[0]; }
+ const T& x() const { static_assert(S > 0); return elements[0]; }
- T y() const {
- static_assert(S > 1);
- return elements[1];
- }
+ T& y() { static_assert(S > 1); return elements[1]; }
+ const T& y() const { static_assert(S > 1); return elements[1]; }
- T z() const {
- static_assert(S > 2);
- return elements[2];
- }
+ T& z() { static_assert(S > 2); return elements[2]; }
+ const T& z() const { static_assert(S > 2); return elements[2]; }
- T w() const {
- static_assert(S > 3);
- return elements[3];
- }
+ T& w() { static_assert(S > 3); return elements[3]; }
+ const T& w() const { static_assert(S > 3); return elements[3]; }
std::string string() const {
std::stringstream str{};