diff --git a/bin/main.cpp b/bin/main.cpp index c5290e2..fe18ce6 100644 --- a/bin/main.cpp +++ b/bin/main.cpp @@ -131,5 +131,6 @@ int main(int argc, char *argv[]) auto [x, y, z] = lerp_1.get_value(); hack::log()("get", x, y, z); + hack::log()("get", lerp_1.x()); } } diff --git a/src/math/vector.hpp b/src/math/vector.hpp index a0b8d37..1ae40d0 100644 --- a/src/math/vector.hpp +++ b/src/math/vector.hpp @@ -2,6 +2,7 @@ #include #include +#include namespace hack { @@ -26,7 +27,10 @@ namespace hack using value_t = decltype(typename generate_tuple::type{}); public: - vector(Args... args) : value_ { args... } {} + vector(Args... args) : value_ { args... } + { + if (std::tuple_size{} < 2) throw std::out_of_range("You try make no valid vector!"); + } vector& operator=(const vector& v) { if (this == &v) return *this; @@ -37,6 +41,28 @@ namespace hack public: value_t get_value() { return value_; }; + auto x() + { + return std::get<0>(value_); + } + + auto y() + { + return std::get<1>(value_); + } + + auto z() + { + if (std::tuple_size{} < 3) throw std::out_of_range("You try get no valid vector date!"); + return std::get<2>(value_); + } + + auto w() + { + if (std::tuple_size{} < 4) throw std::out_of_range("You try get no valid vector date!"); + return std::get<3>(value_); + } + auto length() { return std::sqrt(length_idx(std::make_index_sequence::value>{}));