From 59739ea85bfcbc1459409ab91432b18f25db61d6 Mon Sep 17 00:00:00 2001 From: BlackMATov Date: Sun, 22 Nov 2020 04:01:17 +0700 Subject: [PATCH] remove uninit ctors --- headers/vmath.hpp/vmath_fwd.hpp | 6 ------ headers/vmath.hpp/vmath_mat.hpp | 8 ++------ headers/vmath.hpp/vmath_vec.hpp | 17 ++++++++--------- headers/vmath.hpp/vmath_vec_ops.hpp | 4 ++-- 4 files changed, 12 insertions(+), 23 deletions(-) diff --git a/headers/vmath.hpp/vmath_fwd.hpp b/headers/vmath.hpp/vmath_fwd.hpp index ae546da..7657dbb 100644 --- a/headers/vmath.hpp/vmath_fwd.hpp +++ b/headers/vmath.hpp/vmath_fwd.hpp @@ -16,12 +16,6 @@ #include #include -namespace vmath_hpp -{ - struct uninit_t {}; - inline constexpr uninit_t uninit; -} - namespace vmath_hpp { template < typename T, std::size_t Size > diff --git a/headers/vmath.hpp/vmath_mat.hpp b/headers/vmath.hpp/vmath_mat.hpp index aa1794d..d7acdde 100644 --- a/headers/vmath.hpp/vmath_mat.hpp +++ b/headers/vmath.hpp/vmath_mat.hpp @@ -24,8 +24,6 @@ namespace vmath_hpp::detail {0, 1}, } {} - constexpr explicit mat_base(uninit_t) {} - constexpr explicit mat_base(T v) : rows{ {v, 0}, @@ -67,8 +65,6 @@ namespace vmath_hpp::detail {0, 0, 1}, } {} - constexpr explicit mat_base(uninit_t) {} - constexpr explicit mat_base(T v) : rows{ {v, 0, 0}, @@ -117,8 +113,6 @@ namespace vmath_hpp::detail {0, 0, 0, 1}, } {} - constexpr explicit mat_base(uninit_t) {} - constexpr explicit mat_base(T v) : rows{ {v, 0, 0, 0}, @@ -190,6 +184,8 @@ namespace vmath_hpp using base_type::rows; using base_type::mat_base; + mat() = default; + mat(mat&&) = default; mat& operator=(mat&&) = default; diff --git a/headers/vmath.hpp/vmath_vec.hpp b/headers/vmath.hpp/vmath_vec.hpp index 336fe96..58a9a4f 100644 --- a/headers/vmath.hpp/vmath_vec.hpp +++ b/headers/vmath.hpp/vmath_vec.hpp @@ -16,10 +16,9 @@ namespace vmath_hpp::detail template < typename T > class vec_base { public: - T data[2]; + T data[2]{}; public: - constexpr vec_base() : data{} {} - constexpr explicit vec_base(uninit_t) {} + vec_base() = default; constexpr explicit vec_base(T v) : data{v, v} {} @@ -43,10 +42,9 @@ namespace vmath_hpp::detail template < typename T > class vec_base { public: - T data[3]; + T data[3]{}; public: - constexpr vec_base() : data{} {} - constexpr explicit vec_base(uninit_t) {} + vec_base() = default; constexpr explicit vec_base(T v) : data{v, v, v} {} @@ -76,10 +74,9 @@ namespace vmath_hpp::detail template < typename T > class vec_base { public: - T data[4]; + T data[4]{}; public: - constexpr vec_base() : data{} {} - constexpr explicit vec_base(uninit_t) {} + vec_base() = default; constexpr explicit vec_base(T v) : data{v, v, v, v} {} @@ -147,6 +144,8 @@ namespace vmath_hpp using base_type::data; using base_type::vec_base; + vec() = default; + vec(vec&&) = default; vec& operator=(vec&&) = default; diff --git a/headers/vmath.hpp/vmath_vec_ops.hpp b/headers/vmath.hpp/vmath_vec_ops.hpp index 7fa1f12..a20bfd5 100644 --- a/headers/vmath.hpp/vmath_vec_ops.hpp +++ b/headers/vmath.hpp/vmath_vec_ops.hpp @@ -13,7 +13,7 @@ namespace vmath_hpp::detail { template < typename T, std::size_t Size, typename F > constexpr auto map(const vec& v, F&& f) { - vec, Size> result(uninit); + vec, Size> result; for ( std::size_t i = 0; i < Size; ++i ) { result[i] = f(v[i]); } @@ -22,7 +22,7 @@ namespace vmath_hpp::detail template < typename T, typename U, std::size_t Size, typename F > constexpr auto zip(const vec& l, const vec& r, F&& f) { - vec, Size> result(uninit); + vec, Size> result; for ( std::size_t i = 0; i < Size; ++i ) { result[i] = f(l[i], r[i]); }