mirror of
https://github.com/BlackMATov/vmath.hpp.git
synced 2025-12-15 12:39:47 +07:00
add <<, >> and <<=, >>= operators
This commit is contained in:
@@ -422,6 +422,64 @@ namespace vmath_hpp
|
||||
return (xs = (xs ^ ys));
|
||||
}
|
||||
|
||||
// operator<<
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[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 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 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 >
|
||||
constexpr mat<T, Size>& operator<<=(mat<T, Size>& xs, T y) {
|
||||
return (xs = (xs << y));
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
constexpr mat<T, Size>& operator<<=(mat<T, Size>& xs, const mat<T, Size>& ys) {
|
||||
return (xs = (xs << ys));
|
||||
}
|
||||
|
||||
// operator>>
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[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 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 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 >
|
||||
constexpr mat<T, Size>& operator>>=(mat<T, Size>& xs, T y) {
|
||||
return (xs = (xs >> y));
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
constexpr mat<T, Size>& operator>>=(mat<T, Size>& xs, const mat<T, Size>& ys) {
|
||||
return (xs = (xs >> ys));
|
||||
}
|
||||
|
||||
// operator&&
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
|
||||
@@ -473,6 +473,64 @@ namespace vmath_hpp
|
||||
return (xs = (xs ^ ys));
|
||||
}
|
||||
|
||||
// operator<<
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[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 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 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 >
|
||||
constexpr vec<T, Size>& operator<<=(vec<T, Size>& xs, T y) {
|
||||
return (xs = (xs << y));
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
constexpr vec<T, Size>& operator<<=(vec<T, Size>& xs, const vec<T, Size>& ys) {
|
||||
return (xs = (xs << ys));
|
||||
}
|
||||
|
||||
// operator>>
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[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 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 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 >
|
||||
constexpr vec<T, Size>& operator>>=(vec<T, Size>& xs, T y) {
|
||||
return (xs = (xs >> y));
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
constexpr vec<T, Size>& operator>>=(vec<T, Size>& xs, const vec<T, Size>& ys) {
|
||||
return (xs = (xs >> ys));
|
||||
}
|
||||
|
||||
// operator&&
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
|
||||
Reference in New Issue
Block a user