added noexcept for vector types

This commit is contained in:
2025-05-04 19:13:26 +03:00
parent f6f8bba032
commit 9a38d47b0d
3 changed files with 85 additions and 85 deletions

View File

@@ -17,21 +17,21 @@ namespace omath
constexpr Vector4(const Type& x, const Type& y, const Type& z, const Type& w): Vector3<Type>(x, y, z), w(w)
{
}
constexpr Vector4(): Vector3<Type>(), w(0) {};
constexpr Vector4() noexcept : Vector3<Type>(), w(0) {};
[[nodiscard]]
constexpr bool operator==(const Vector4& src) const
constexpr bool operator==(const Vector4& src) const noexcept
{
return Vector3<Type>::operator==(src) && w == src.w;
}
[[nodiscard]]
constexpr bool operator!=(const Vector4& src) const
constexpr bool operator!=(const Vector4& src) const noexcept
{
return !(*this == src);
}
constexpr Vector4& operator+=(const Vector4& v)
constexpr Vector4& operator+=(const Vector4& v) noexcept
{
Vector3<Type>::operator+=(v);
w += v.w;
@@ -39,7 +39,7 @@ namespace omath
return *this;
}
constexpr Vector4& operator-=(const Vector4& v)
constexpr Vector4& operator-=(const Vector4& v) noexcept
{
Vector3<Type>::operator-=(v);
w -= v.w;
@@ -47,7 +47,7 @@ namespace omath
return *this;
}
constexpr Vector4& operator*=(const float scalar)
constexpr Vector4& operator*=(const float scalar) noexcept
{
Vector3<Type>::operator*=(scalar);
w *= scalar;
@@ -55,7 +55,7 @@ namespace omath
return *this;
}
constexpr Vector4& operator*=(const Vector4& v)
constexpr Vector4& operator*=(const Vector4& v) noexcept
{
Vector3<Type>::operator*=(v);
w *= v.w;
@@ -63,7 +63,7 @@ namespace omath
return *this;
}
constexpr Vector4& operator/=(const float scalar)
constexpr Vector4& operator/=(const float scalar) noexcept
{
Vector3<Type>::operator/=(scalar);
w /= scalar;
@@ -71,36 +71,36 @@ namespace omath
return *this;
}
constexpr Vector4& operator/=(const Vector4& v)
constexpr Vector4& operator/=(const Vector4& v) noexcept
{
Vector3<Type>::operator/=(v);
w /= v.w;
return *this;
}
[[nodiscard]] constexpr Type length_sqr() const
[[nodiscard]] constexpr Type length_sqr() const noexcept
{
return Vector3<Type>::length_sqr() + w * w;
}
[[nodiscard]] constexpr Type dot(const Vector4& other) const
[[nodiscard]] constexpr Type dot(const Vector4& other) const noexcept
{
return Vector3<Type>::dot(other) + w * other.w;
}
[[nodiscard]] Vector3<Type> length() const
[[nodiscard]] Vector3<Type> length() const noexcept
{
return std::sqrt(length_sqr());
}
constexpr Vector4& abs()
constexpr Vector4& abs() noexcept
{
Vector3<Type>::abs();
w = w < 0.f ? -w : w;
return *this;
}
constexpr Vector4& clamp(const Type& min, const Type& max)
constexpr Vector4& clamp(const Type& min, const Type& max) noexcept
{
this->x = std::clamp(this->x, min, max);
this->y = std::clamp(this->y, min, max);
@@ -110,56 +110,56 @@ namespace omath
}
[[nodiscard]]
constexpr Vector4 operator-() const
constexpr Vector4 operator-() const noexcept
{
return {-this->x, -this->y, -this->z, -w};
}
[[nodiscard]]
constexpr Vector4 operator+(const Vector4& v) const
constexpr Vector4 operator+(const Vector4& v) const noexcept
{
return {this->x + v.x, this->y + v.y, this->z + v.z, w + v.w};
}
[[nodiscard]]
constexpr Vector4 operator-(const Vector4& v) const
constexpr Vector4 operator-(const Vector4& v) const noexcept
{
return {this->x - v.x, this->y - v.y, this->z - v.z, w - v.w};
}
[[nodiscard]]
constexpr Vector4 operator*(const Type& scalar) const
constexpr Vector4 operator*(const Type& scalar) const noexcept
{
return {this->x * scalar, this->y * scalar, this->z * scalar, w * scalar};
}
[[nodiscard]]
constexpr Vector4 operator*(const Vector4& v) const
constexpr Vector4 operator*(const Vector4& v) const noexcept
{
return {this->x * v.x, this->y * v.y, this->z * v.z, w * v.w};
}
[[nodiscard]]
constexpr Vector4 operator/(const Type& scalar) const
constexpr Vector4 operator/(const Type& scalar) const noexcept
{
return {this->x / scalar, this->y / scalar, this->z / scalar, w / scalar};
}
[[nodiscard]]
constexpr Vector4 operator/(const Vector4& v) const
constexpr Vector4 operator/(const Vector4& v) const noexcept
{
return {this->x / v.x, this->y / v.y, this->z / v.z, w / v.w};
}
[[nodiscard]]
constexpr Type sum() const
constexpr Type sum() const noexcept
{
return Vector3<Type>::sum() + w;
}
#ifdef OMATH_IMGUI_INTEGRATION
[[nodiscard]]
ImVec4 to_im_vec4() const
ImVec4 to_im_vec4() const noexcept
{
return {
static_cast<float>(this->x),