mirror of
https://github.com/BlackMATov/vmath.hpp.git
synced 2025-12-16 14:11:28 +07:00
operators non-arithmetic T support
This commit is contained in:
@@ -195,45 +195,45 @@ namespace vmath_hpp
|
||||
// +operator
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr mat<T, Size> operator+(const mat<T, Size>& xs) {
|
||||
[[nodiscard]] constexpr auto operator+(const mat<T, Size>& xs) {
|
||||
return xs;
|
||||
}
|
||||
|
||||
// -operator
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr mat<T, Size> operator-(const mat<T, Size>& xs) {
|
||||
[[nodiscard]] constexpr auto operator-(const mat<T, Size>& xs) {
|
||||
return map_join([](const vec<T, Size>& x){ return -x; }, xs);
|
||||
}
|
||||
|
||||
// ~operator
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr mat<T, Size> operator~(const mat<T, Size>& xs) {
|
||||
[[nodiscard]] constexpr auto operator~(const mat<T, Size>& xs) {
|
||||
return map_join([](const vec<T, Size>& x){ return ~x; }, xs);
|
||||
}
|
||||
|
||||
// !operator
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr mat<bool, Size> operator!(const mat<T, Size>& xs) {
|
||||
[[nodiscard]] constexpr auto operator!(const mat<T, Size>& xs) {
|
||||
return map_join([](const vec<T, Size>& x){ return !x; }, xs);
|
||||
}
|
||||
|
||||
// operator+
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr mat<T, Size> operator+(const mat<T, Size>& xs, T y) {
|
||||
[[nodiscard]] constexpr auto operator+(const mat<T, Size>& xs, T y) {
|
||||
return map_join([y](const vec<T, Size>& x){ return x + y; }, xs);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr mat<T, Size> operator+(T x, const mat<T, Size>& ys) {
|
||||
[[nodiscard]] constexpr auto operator+(T x, const mat<T, Size>& ys) {
|
||||
return map_join([x](const vec<T, Size>& y){ return x + y; }, ys);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr mat<T, Size> operator+(const mat<T, Size>& xs, const mat<T, Size>& ys) {
|
||||
[[nodiscard]] constexpr auto operator+(const mat<T, Size>& xs, const mat<T, Size>& ys) {
|
||||
return map_join([](const vec<T, Size>& x, const vec<T, Size>& y){ return x + y; }, xs, ys);
|
||||
}
|
||||
|
||||
@@ -252,17 +252,17 @@ namespace vmath_hpp
|
||||
// operator-
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr mat<T, Size> operator-(const mat<T, Size>& xs, T y) {
|
||||
[[nodiscard]] constexpr auto operator-(const mat<T, Size>& xs, T y) {
|
||||
return map_join([y](const vec<T, Size>& x){ return x - y; }, xs);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr mat<T, Size> operator-(T x, const mat<T, Size>& ys) {
|
||||
[[nodiscard]] constexpr auto operator-(T x, const mat<T, Size>& ys) {
|
||||
return map_join([x](const vec<T, Size>& y){ return x - y; }, ys);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr mat<T, Size> operator-(const mat<T, Size>& xs, const mat<T, Size>& ys) {
|
||||
[[nodiscard]] constexpr auto operator-(const mat<T, Size>& xs, const mat<T, Size>& ys) {
|
||||
return map_join([](const vec<T, Size>& x, const vec<T, Size>& y){ return x - y; }, xs, ys);
|
||||
}
|
||||
|
||||
@@ -281,24 +281,24 @@ namespace vmath_hpp
|
||||
// operator*
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr mat<T, Size> operator*(const mat<T, Size>& xs, T y) {
|
||||
[[nodiscard]] constexpr auto operator*(const mat<T, Size>& xs, T y) {
|
||||
return map_join([y](const vec<T, Size>& x){ return x * y; }, xs);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr mat<T, Size> operator*(T x, const mat<T, Size>& ys) {
|
||||
[[nodiscard]] constexpr auto operator*(T x, const mat<T, Size>& ys) {
|
||||
return map_join([x](const vec<T, Size>& y){ return x * y; }, ys);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr vec<T, Size> operator*(const vec<T, Size>& xs, const mat<T, Size>& ys) {
|
||||
[[nodiscard]] constexpr auto operator*(const vec<T, Size>& xs, const mat<T, Size>& ys) {
|
||||
return fold_join([](const vec<T, Size>& acc, T x, const vec<T, Size>& y){
|
||||
return acc + x * y;
|
||||
}, vec<T, Size>{}, xs, ys);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr mat<T, Size> operator*(const mat<T, Size>& xs, const mat<T, Size>& ys) {
|
||||
[[nodiscard]] constexpr auto operator*(const mat<T, Size>& xs, const mat<T, Size>& ys) {
|
||||
return map_join([&ys](const vec<T, Size>& x){
|
||||
return x * ys;
|
||||
}, xs);
|
||||
@@ -324,12 +324,12 @@ namespace vmath_hpp
|
||||
// operator/
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr mat<T, Size> operator/(const mat<T, Size>& xs, T y) {
|
||||
[[nodiscard]] constexpr auto operator/(const mat<T, Size>& xs, T y) {
|
||||
return map_join([y](const vec<T, Size>& x){ return x / y; }, xs);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr mat<T, Size> operator/(T x, const mat<T, Size>& ys) {
|
||||
[[nodiscard]] constexpr auto operator/(T x, const mat<T, Size>& ys) {
|
||||
return map_join([x](const vec<T, Size>& y){ return x / y; }, ys);
|
||||
}
|
||||
|
||||
@@ -343,17 +343,17 @@ namespace vmath_hpp
|
||||
// operator&
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr mat<T, Size> operator&(const mat<T, Size>& xs, T y) {
|
||||
[[nodiscard]] constexpr auto operator&(const mat<T, Size>& xs, T y) {
|
||||
return map_join([y](const vec<T, Size>& x){ return x & y; }, xs);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr mat<T, Size> operator&(T x, const mat<T, Size>& ys) {
|
||||
[[nodiscard]] constexpr auto operator&(T x, const mat<T, Size>& ys) {
|
||||
return map_join([x](const vec<T, Size>& y){ return x & y; }, ys);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr mat<T, Size> operator&(const mat<T, Size>& xs, const mat<T, Size>& ys) {
|
||||
[[nodiscard]] constexpr auto operator&(const mat<T, Size>& xs, const mat<T, Size>& ys) {
|
||||
return map_join([](const vec<T, Size>& x, const vec<T, Size>& y){ return x & y; }, xs, ys);
|
||||
}
|
||||
|
||||
@@ -372,17 +372,17 @@ namespace vmath_hpp
|
||||
// operator|
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr mat<T, Size> operator|(const mat<T, Size>& xs, T y) {
|
||||
[[nodiscard]] constexpr auto operator|(const mat<T, Size>& xs, T y) {
|
||||
return map_join([y](const vec<T, Size>& x){ return x | y; }, xs);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr mat<T, Size> operator|(T x, const mat<T, Size>& ys) {
|
||||
[[nodiscard]] constexpr auto operator|(T x, const mat<T, Size>& ys) {
|
||||
return map_join([x](const vec<T, Size>& y){ return x | y; }, ys);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr mat<T, Size> operator|(const mat<T, Size>& xs, const mat<T, Size>& ys) {
|
||||
[[nodiscard]] constexpr auto operator|(const mat<T, Size>& xs, const mat<T, Size>& ys) {
|
||||
return map_join([](const vec<T, Size>& x, const vec<T, Size>& y){ return x | y; }, xs, ys);
|
||||
}
|
||||
|
||||
@@ -401,17 +401,17 @@ namespace vmath_hpp
|
||||
// operator^
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr mat<T, Size> operator^(const mat<T, Size>& xs, T y) {
|
||||
[[nodiscard]] constexpr auto operator^(const mat<T, Size>& xs, T y) {
|
||||
return map_join([y](const vec<T, Size>& x){ return x ^ y; }, xs);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr mat<T, Size> operator^(T x, const mat<T, Size>& ys) {
|
||||
[[nodiscard]] constexpr auto operator^(T x, const mat<T, Size>& ys) {
|
||||
return map_join([x](const vec<T, Size>& y){ return x ^ y; }, ys);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr mat<T, Size> operator^(const mat<T, Size>& xs, const mat<T, Size>& ys) {
|
||||
[[nodiscard]] constexpr auto operator^(const mat<T, Size>& xs, const mat<T, Size>& ys) {
|
||||
return map_join([](const vec<T, Size>& x, const vec<T, Size>& y){ return x ^ y; }, xs, ys);
|
||||
}
|
||||
|
||||
@@ -430,34 +430,34 @@ namespace vmath_hpp
|
||||
// operator&&
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr mat<bool, Size> operator&&(const mat<T, Size>& xs, T y) {
|
||||
[[nodiscard]] constexpr auto operator&&(const mat<T, Size>& xs, T y) {
|
||||
return map_join([y](const vec<T, Size>& x){ return x && y; }, xs);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr mat<bool, Size> operator&&(T x, const mat<T, Size>& ys) {
|
||||
[[nodiscard]] constexpr auto operator&&(T x, const mat<T, Size>& ys) {
|
||||
return map_join([x](const vec<T, Size>& y){ return x && y; }, ys);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr mat<bool, Size> operator&&(const mat<T, Size>& xs, const mat<T, Size>& ys) {
|
||||
[[nodiscard]] constexpr auto operator&&(const mat<T, Size>& xs, const mat<T, Size>& ys) {
|
||||
return map_join([](const vec<T, Size>& x, const vec<T, Size>& y){ return x && y; }, xs, ys);
|
||||
}
|
||||
|
||||
// operator||
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr mat<bool, Size> operator||(const mat<T, Size>& xs, T y) {
|
||||
[[nodiscard]] constexpr auto operator||(const mat<T, Size>& xs, T y) {
|
||||
return map_join([y](const vec<T, Size>& x){ return x || y; }, xs);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr mat<bool, Size> operator||(T x, const mat<T, Size>& ys) {
|
||||
[[nodiscard]] constexpr auto operator||(T x, const mat<T, Size>& ys) {
|
||||
return map_join([x](const vec<T, Size>& y){ return x || y; }, ys);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr mat<bool, Size> operator||(const mat<T, Size>& xs, const mat<T, Size>& ys) {
|
||||
[[nodiscard]] constexpr auto operator||(const mat<T, Size>& xs, const mat<T, Size>& ys) {
|
||||
return map_join([](const vec<T, Size>& x, const vec<T, Size>& y){ return x || y; }, xs, ys);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,21 +23,21 @@ namespace vmath_hpp
|
||||
// +operator
|
||||
|
||||
template < typename T >
|
||||
[[nodiscard]] constexpr qua<T> operator+(const qua<T>& xs) {
|
||||
[[nodiscard]] constexpr auto operator+(const qua<T>& xs) {
|
||||
return xs;
|
||||
}
|
||||
|
||||
// -operator
|
||||
|
||||
template < typename T >
|
||||
[[nodiscard]] constexpr qua<T> operator-(const qua<T>& xs) {
|
||||
[[nodiscard]] constexpr auto operator-(const qua<T>& xs) {
|
||||
return qua(-vec<T, 4>{xs});
|
||||
}
|
||||
|
||||
// operator+
|
||||
|
||||
template < typename T >
|
||||
[[nodiscard]] constexpr qua<T> operator+(const qua<T>& xs, const qua<T>& ys) {
|
||||
[[nodiscard]] constexpr auto operator+(const qua<T>& xs, const qua<T>& ys) {
|
||||
return qua(vec{xs} + vec{ys});
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace vmath_hpp
|
||||
// operator-
|
||||
|
||||
template < typename T >
|
||||
[[nodiscard]] constexpr qua<T> operator-(const qua<T>& xs, const qua<T>& ys) {
|
||||
[[nodiscard]] constexpr auto operator-(const qua<T>& xs, const qua<T>& ys) {
|
||||
return qua(vec{xs} - vec{ys});
|
||||
}
|
||||
|
||||
@@ -65,30 +65,30 @@ namespace vmath_hpp
|
||||
// operator*
|
||||
|
||||
template < typename T >
|
||||
[[nodiscard]] constexpr qua<T> operator*(const qua<T>& xs, T y) {
|
||||
[[nodiscard]] constexpr auto operator*(const qua<T>& xs, T y) {
|
||||
return qua(vec{xs} * y);
|
||||
}
|
||||
|
||||
template < typename T >
|
||||
[[nodiscard]] constexpr qua<T> operator*(T x, const qua<T>& ys) {
|
||||
[[nodiscard]] constexpr auto operator*(T x, const qua<T>& ys) {
|
||||
return qua(x * vec{ys});
|
||||
}
|
||||
|
||||
template < typename T >
|
||||
[[nodiscard]] constexpr vec<T, 3> operator*(const vec<T, 3>& xs, const qua<T>& ys) {
|
||||
[[nodiscard]] constexpr auto operator*(const vec<T, 3>& xs, const qua<T>& ys) {
|
||||
/// REFERENCE:
|
||||
/// http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/transforms/
|
||||
|
||||
const vec qv2 = cross(ys.v, xs) * T(2);
|
||||
const vec qv2 = cross(ys.v, xs) * T{2};
|
||||
return xs + qv2 * ys.s + cross(ys.v, qv2);
|
||||
}
|
||||
|
||||
template < typename T >
|
||||
[[nodiscard]] constexpr qua<T> operator*(const qua<T>& xs, const qua<T>& ys) {
|
||||
[[nodiscard]] constexpr auto operator*(const qua<T>& xs, const qua<T>& ys) {
|
||||
/// REFERENCE:
|
||||
/// http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/arithmetic/
|
||||
|
||||
return {
|
||||
return qua{
|
||||
cross(ys.v, xs.v) + ys.s * xs.v + xs.s * ys.v,
|
||||
ys.s * xs.s - dot(ys.v, xs.v)};
|
||||
}
|
||||
@@ -113,12 +113,12 @@ namespace vmath_hpp
|
||||
// operator/
|
||||
|
||||
template < typename T >
|
||||
[[nodiscard]] constexpr qua<T> operator/(const qua<T>& xs, T y) {
|
||||
[[nodiscard]] constexpr auto operator/(const qua<T>& xs, T y) {
|
||||
return qua(vec{xs} / y);
|
||||
}
|
||||
|
||||
template < typename T >
|
||||
[[nodiscard]] constexpr qua<T> operator/(T x, const qua<T>& ys) {
|
||||
[[nodiscard]] constexpr auto operator/(T x, const qua<T>& ys) {
|
||||
return qua(x / vec{ys});
|
||||
}
|
||||
|
||||
|
||||
@@ -199,45 +199,45 @@ namespace vmath_hpp
|
||||
// +operator
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr vec<T, Size> operator+(const vec<T, Size>& xs) {
|
||||
[[nodiscard]] constexpr auto operator+(const vec<T, Size>& xs) {
|
||||
return xs;
|
||||
}
|
||||
|
||||
// -operator
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr vec<T, Size> operator-(const vec<T, Size>& xs) {
|
||||
[[nodiscard]] constexpr auto operator-(const vec<T, Size>& xs) {
|
||||
return map_join([](T x){ return -x; }, xs);
|
||||
}
|
||||
|
||||
// ~operator
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr vec<T, Size> operator~(const vec<T, Size>& xs) {
|
||||
[[nodiscard]] constexpr auto operator~(const vec<T, Size>& xs) {
|
||||
return map_join([](T x){ return ~x; }, xs);
|
||||
}
|
||||
|
||||
// !operator
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr vec<bool, Size> operator!(const vec<T, Size>& xs) {
|
||||
[[nodiscard]] constexpr auto operator!(const vec<T, Size>& xs) {
|
||||
return map_join([](T x){ return !x; }, xs);
|
||||
}
|
||||
|
||||
// operator+
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr vec<T, Size> operator+(const vec<T, Size>& xs, T y) {
|
||||
[[nodiscard]] constexpr auto operator+(const vec<T, Size>& xs, T y) {
|
||||
return map_join([y](T x){ return x + y; }, xs);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr vec<T, Size> operator+(T x, const vec<T, Size>& ys) {
|
||||
[[nodiscard]] constexpr auto operator+(T x, const vec<T, Size>& ys) {
|
||||
return map_join([x](T y){ return x + y; }, ys);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr vec<T, Size> operator+(const vec<T, Size>& xs, const vec<T, Size>& ys) {
|
||||
[[nodiscard]] constexpr auto operator+(const vec<T, Size>& xs, const vec<T, Size>& ys) {
|
||||
return map_join([](T x, T y){ return x + y; }, xs, ys);
|
||||
}
|
||||
|
||||
@@ -256,17 +256,17 @@ namespace vmath_hpp
|
||||
// operator-
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr vec<T, Size> operator-(const vec<T, Size>& xs, T y) {
|
||||
[[nodiscard]] constexpr auto operator-(const vec<T, Size>& xs, T y) {
|
||||
return map_join([y](T x){ return x - y; }, xs);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr vec<T, Size> operator-(T x, const vec<T, Size>& ys) {
|
||||
[[nodiscard]] constexpr auto operator-(T x, const vec<T, Size>& ys) {
|
||||
return map_join([x](T y){ return x - y; }, ys);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr vec<T, Size> operator-(const vec<T, Size>& xs, const vec<T, Size>& ys) {
|
||||
[[nodiscard]] constexpr auto operator-(const vec<T, Size>& xs, const vec<T, Size>& ys) {
|
||||
return map_join([](T x, T y){ return x - y; }, xs, ys);
|
||||
}
|
||||
|
||||
@@ -285,17 +285,17 @@ namespace vmath_hpp
|
||||
// operator*
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr vec<T, Size> operator*(const vec<T, Size>& xs, T y) {
|
||||
[[nodiscard]] constexpr auto operator*(const vec<T, Size>& xs, T y) {
|
||||
return map_join([y](T x){ return x * y; }, xs);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr vec<T, Size> operator*(T x, const vec<T, Size>& ys) {
|
||||
[[nodiscard]] constexpr auto operator*(T x, const vec<T, Size>& ys) {
|
||||
return map_join([x](T y){ return x * y; }, ys);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr vec<T, Size> operator*(const vec<T, Size>& xs, const vec<T, Size>& ys) {
|
||||
[[nodiscard]] constexpr auto operator*(const vec<T, Size>& xs, const vec<T, Size>& ys) {
|
||||
return map_join([](T x, T y){ return x * y; }, xs, ys);
|
||||
}
|
||||
|
||||
@@ -314,17 +314,17 @@ namespace vmath_hpp
|
||||
// operator/
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr vec<T, Size> operator/(const vec<T, Size>& xs, T y) {
|
||||
[[nodiscard]] constexpr auto operator/(const vec<T, Size>& xs, T y) {
|
||||
return map_join([y](T x){ return x / y; }, xs);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr vec<T, Size> operator/(T x, const vec<T, Size>& ys) {
|
||||
[[nodiscard]] constexpr auto operator/(T x, const vec<T, Size>& ys) {
|
||||
return map_join([x](T y){ return x / y; }, ys);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr vec<T, Size> operator/(const vec<T, Size>& xs, const vec<T, Size>& ys) {
|
||||
[[nodiscard]] constexpr auto operator/(const vec<T, Size>& xs, const vec<T, Size>& ys) {
|
||||
return map_join([](T x, T y){ return x / y; }, xs, ys);
|
||||
}
|
||||
|
||||
@@ -343,17 +343,17 @@ namespace vmath_hpp
|
||||
// operator&
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr vec<T, Size> operator&(const vec<T, Size>& xs, T y) {
|
||||
[[nodiscard]] constexpr auto operator&(const vec<T, Size>& xs, T y) {
|
||||
return map_join([y](T x){ return x & y; }, xs);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr vec<T, Size> operator&(T x, const vec<T, Size>& ys) {
|
||||
[[nodiscard]] constexpr auto operator&(T x, const vec<T, Size>& ys) {
|
||||
return map_join([x](T y){ return x & y; }, ys);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr vec<T, Size> operator&(const vec<T, Size>& xs, const vec<T, Size>& ys) {
|
||||
[[nodiscard]] constexpr auto operator&(const vec<T, Size>& xs, const vec<T, Size>& ys) {
|
||||
return map_join([](T x, T y){ return x & y; }, xs, ys);
|
||||
}
|
||||
|
||||
@@ -372,17 +372,17 @@ namespace vmath_hpp
|
||||
// operator|
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr vec<T, Size> operator|(const vec<T, Size>& xs, T y) {
|
||||
[[nodiscard]] constexpr auto operator|(const vec<T, Size>& xs, T y) {
|
||||
return map_join([y](T x){ return x | y; }, xs);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr vec<T, Size> operator|(T x, const vec<T, Size>& ys) {
|
||||
[[nodiscard]] constexpr auto operator|(T x, const vec<T, Size>& ys) {
|
||||
return map_join([x](T y){ return x | y; }, ys);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr vec<T, Size> operator|(const vec<T, Size>& xs, const vec<T, Size>& ys) {
|
||||
[[nodiscard]] constexpr auto operator|(const vec<T, Size>& xs, const vec<T, Size>& ys) {
|
||||
return map_join([](T x, T y){ return x | y; }, xs, ys);
|
||||
}
|
||||
|
||||
@@ -401,17 +401,17 @@ namespace vmath_hpp
|
||||
// operator^
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr vec<T, Size> operator^(const vec<T, Size>& xs, T y) {
|
||||
[[nodiscard]] constexpr auto operator^(const vec<T, Size>& xs, T y) {
|
||||
return map_join([y](T x){ return x ^ y; }, xs);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr vec<T, Size> operator^(T x, const vec<T, Size>& ys) {
|
||||
[[nodiscard]] constexpr auto operator^(T x, const vec<T, Size>& ys) {
|
||||
return map_join([x](T y){ return x ^ y; }, ys);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr vec<T, Size> operator^(const vec<T, Size>& xs, const vec<T, Size>& ys) {
|
||||
[[nodiscard]] constexpr auto operator^(const vec<T, Size>& xs, const vec<T, Size>& ys) {
|
||||
return map_join([](T x, T y){ return x ^ y; }, xs, ys);
|
||||
}
|
||||
|
||||
@@ -430,34 +430,34 @@ namespace vmath_hpp
|
||||
// operator&&
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr vec<bool, Size> operator&&(const vec<T, Size>& xs, T y) {
|
||||
[[nodiscard]] constexpr auto operator&&(const vec<T, Size>& xs, T y) {
|
||||
return map_join([y](T x){ return x && y; }, xs);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr vec<bool, Size> operator&&(T x, const vec<T, Size>& ys) {
|
||||
[[nodiscard]] constexpr auto operator&&(T x, const vec<T, Size>& ys) {
|
||||
return map_join([x](T y){ return x && y; }, ys);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr vec<bool, Size> operator&&(const vec<T, Size>& xs, const vec<T, Size>& ys) {
|
||||
[[nodiscard]] constexpr auto operator&&(const vec<T, Size>& xs, const vec<T, Size>& ys) {
|
||||
return map_join([](T x, T y){ return x && y; }, xs, ys);
|
||||
}
|
||||
|
||||
// operator||
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr vec<bool, Size> operator||(const vec<T, Size>& xs, T y) {
|
||||
[[nodiscard]] constexpr auto operator||(const vec<T, Size>& xs, T y) {
|
||||
return map_join([y](T x){ return x || y; }, xs);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr vec<bool, Size> operator||(T x, const vec<T, Size>& ys) {
|
||||
[[nodiscard]] constexpr auto operator||(T x, const vec<T, Size>& ys) {
|
||||
return map_join([x](T y){ return x || y; }, ys);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr vec<bool, Size> operator||(const vec<T, Size>& xs, const vec<T, Size>& ys) {
|
||||
[[nodiscard]] constexpr auto operator||(const vec<T, Size>& xs, const vec<T, Size>& ys) {
|
||||
return map_join([](T x, T y){ return x || y; }, xs, ys);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user