mirror of
https://github.com/BlackMATov/vmath.hpp.git
synced 2025-12-15 04:35:25 +07:00
remove uninit ctors
This commit is contained in:
@@ -16,12 +16,6 @@
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
namespace vmath_hpp
|
||||
{
|
||||
struct uninit_t {};
|
||||
inline constexpr uninit_t uninit;
|
||||
}
|
||||
|
||||
namespace vmath_hpp
|
||||
{
|
||||
template < typename T, std::size_t Size >
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -16,10 +16,9 @@ namespace vmath_hpp::detail
|
||||
template < typename T >
|
||||
class vec_base<T, 2> {
|
||||
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<T, 3> {
|
||||
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<T, 4> {
|
||||
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;
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace vmath_hpp::detail
|
||||
{
|
||||
template < typename T, std::size_t Size, typename F >
|
||||
constexpr auto map(const vec<T, Size>& v, F&& f) {
|
||||
vec<std::invoke_result_t<F,T>, Size> result(uninit);
|
||||
vec<std::invoke_result_t<F, T>, 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<T, Size>& l, const vec<U, Size>& r, F&& f) {
|
||||
vec<std::invoke_result_t<F, T, U>, Size> result(uninit);
|
||||
vec<std::invoke_result_t<F, T, U>, Size> result;
|
||||
for ( std::size_t i = 0; i < Size; ++i ) {
|
||||
result[i] = f(l[i], r[i]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user