mirror of
https://github.com/BlackMATov/vmath.hpp.git
synced 2026-01-04 17:21:04 +07:00
add zero and identity ctors
This commit is contained in:
@@ -42,6 +42,12 @@ namespace vmath_hpp
|
||||
{
|
||||
struct uninit_t { explicit uninit_t() = default; };
|
||||
inline constexpr uninit_t uninit{};
|
||||
|
||||
struct zero_init_t { explicit zero_init_t() = default; };
|
||||
inline constexpr zero_init_t zero_init{};
|
||||
|
||||
struct identity_init_t { explicit identity_init_t() = default; };
|
||||
inline constexpr identity_init_t identity_init{};
|
||||
}
|
||||
|
||||
namespace vmath_hpp
|
||||
|
||||
@@ -23,12 +23,20 @@ namespace vmath_hpp::detail
|
||||
row_type rows[2];
|
||||
public:
|
||||
constexpr mat_base()
|
||||
: mat_base(identity_init) {}
|
||||
|
||||
constexpr explicit mat_base(uninit_t) {}
|
||||
|
||||
constexpr explicit mat_base(zero_init_t)
|
||||
: rows{
|
||||
{T{0}, T{0}},
|
||||
{T{0}, T{0}}} {}
|
||||
|
||||
constexpr explicit mat_base(identity_init_t)
|
||||
: rows{
|
||||
{T{1}, T{0}},
|
||||
{T{0}, T{1}}} {}
|
||||
|
||||
constexpr explicit mat_base(uninit_t) {}
|
||||
|
||||
constexpr explicit mat_base(T d)
|
||||
: rows{
|
||||
{d, T{0}},
|
||||
@@ -59,13 +67,22 @@ namespace vmath_hpp::detail
|
||||
row_type rows[3];
|
||||
public:
|
||||
constexpr mat_base()
|
||||
: mat_base(identity_init) {}
|
||||
|
||||
constexpr explicit mat_base(uninit_t) {}
|
||||
|
||||
constexpr explicit mat_base(zero_init_t)
|
||||
: rows{
|
||||
{T{0}, T{0}, T{0}},
|
||||
{T{0}, T{0}, T{0}},
|
||||
{T{0}, T{0}, T{0}}} {}
|
||||
|
||||
constexpr explicit mat_base(identity_init_t)
|
||||
: rows{
|
||||
{T{1}, T{0}, T{0}},
|
||||
{T{0}, T{1}, T{0}},
|
||||
{T{0}, T{0}, T{1}}} {}
|
||||
|
||||
constexpr explicit mat_base(uninit_t) {}
|
||||
|
||||
constexpr explicit mat_base(T d)
|
||||
: rows{
|
||||
{d, T{0}, T{0}},
|
||||
@@ -122,14 +139,24 @@ namespace vmath_hpp::detail
|
||||
row_type rows[4];
|
||||
public:
|
||||
constexpr mat_base()
|
||||
: mat_base(identity_init) {}
|
||||
|
||||
constexpr explicit mat_base(uninit_t) {}
|
||||
|
||||
constexpr explicit mat_base(zero_init_t)
|
||||
: rows{
|
||||
{T{0}, T{0}, T{0}, T{0}},
|
||||
{T{0}, T{0}, T{0}, T{0}},
|
||||
{T{0}, T{0}, T{0}, T{0}},
|
||||
{T{0}, T{0}, T{0}, T{0}}} {}
|
||||
|
||||
constexpr explicit mat_base(identity_init_t)
|
||||
: rows{
|
||||
{T{1}, T{0}, T{0}, T{0}},
|
||||
{T{0}, T{1}, T{0}, T{0}},
|
||||
{T{0}, T{0}, T{1}, T{0}},
|
||||
{T{0}, T{0}, T{0}, T{1}}} {}
|
||||
|
||||
constexpr explicit mat_base(uninit_t) {}
|
||||
|
||||
constexpr explicit mat_base(T d)
|
||||
: rows{
|
||||
{d, T{0}, T{0}, T{0}},
|
||||
|
||||
@@ -20,10 +20,16 @@ namespace vmath_hpp::detail
|
||||
T s;
|
||||
public:
|
||||
constexpr qua_base()
|
||||
: v{T{0}}, s{1} {}
|
||||
: qua_base(identity_init) {}
|
||||
|
||||
constexpr explicit qua_base(uninit_t) {}
|
||||
|
||||
constexpr explicit qua_base(zero_init_t)
|
||||
: v{T{0}}, s{0} {}
|
||||
|
||||
constexpr explicit qua_base(identity_init_t)
|
||||
: v{T{0}}, s{1} {}
|
||||
|
||||
constexpr qua_base(T vx, T vy, T vz, T s)
|
||||
: v{vx, vy, vz}, s{s} {}
|
||||
|
||||
|
||||
@@ -19,10 +19,13 @@ namespace vmath_hpp::detail
|
||||
T x, y;
|
||||
public:
|
||||
constexpr vec_base()
|
||||
: x{0}, y{0} {}
|
||||
: vec_base(zero_init) {}
|
||||
|
||||
constexpr explicit vec_base(uninit_t) {}
|
||||
|
||||
constexpr explicit vec_base(zero_init_t)
|
||||
: x{0}, y{0} {}
|
||||
|
||||
constexpr explicit vec_base(T v)
|
||||
: x{v}, y{v} {}
|
||||
|
||||
@@ -52,10 +55,13 @@ namespace vmath_hpp::detail
|
||||
T x, y, z;
|
||||
public:
|
||||
constexpr vec_base()
|
||||
: x{0}, y{0}, z{0} {}
|
||||
: vec_base(zero_init) {}
|
||||
|
||||
constexpr explicit vec_base(uninit_t) {}
|
||||
|
||||
constexpr explicit vec_base(zero_init_t)
|
||||
: x{0}, y{0}, z{0} {}
|
||||
|
||||
constexpr explicit vec_base(T v)
|
||||
: x{v}, y{v}, z{v} {}
|
||||
|
||||
@@ -97,10 +103,13 @@ namespace vmath_hpp::detail
|
||||
T x, y, z, w;
|
||||
public:
|
||||
constexpr vec_base()
|
||||
: x{0}, y{0}, z{0}, w{0} {}
|
||||
: vec_base(zero_init) {}
|
||||
|
||||
constexpr explicit vec_base(uninit_t) {}
|
||||
|
||||
constexpr explicit vec_base(zero_init_t)
|
||||
: x{0}, y{0}, z{0}, w{0} {}
|
||||
|
||||
constexpr explicit vec_base(T v)
|
||||
: x{v}, y{v}, z{v}, w{v} {}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user