mirror of
https://github.com/BlackMATov/vmath.hpp.git
synced 2025-12-16 14:11:28 +07:00
postfix and infix increment operators
This commit is contained in:
@@ -187,6 +187,38 @@ namespace vmath_hpp
|
||||
return map_join([](const vec<T, Size>& x){ return !x; }, xs);
|
||||
}
|
||||
|
||||
// ++operator
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
constexpr mat<T, Size>& operator++(mat<T, Size>& xs) {
|
||||
return (xs = xs + T{1});
|
||||
}
|
||||
|
||||
// --operator
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
constexpr mat<T, Size>& operator--(mat<T, Size>& xs) {
|
||||
return (xs = xs - T{1});
|
||||
}
|
||||
|
||||
// operator++
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
constexpr mat<T, Size> operator++(mat<T, Size>& xs, int) {
|
||||
mat<T, Size> ys = xs;
|
||||
++xs;
|
||||
return ys;
|
||||
}
|
||||
|
||||
// operator--
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
constexpr mat<T, Size> operator--(mat<T, Size>& xs, int) {
|
||||
mat<T, Size> ys = xs;
|
||||
--xs;
|
||||
return ys;
|
||||
}
|
||||
|
||||
// operator+
|
||||
|
||||
template < typename T, typename U, std::size_t Size >
|
||||
|
||||
@@ -238,6 +238,38 @@ namespace vmath_hpp
|
||||
return map_join([](T x){ return !x; }, xs);
|
||||
}
|
||||
|
||||
// ++operator
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
constexpr vec<T, Size>& operator++(vec<T, Size>& xs) {
|
||||
return (xs = xs + T{1});
|
||||
}
|
||||
|
||||
// --operator
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
constexpr vec<T, Size>& operator--(vec<T, Size>& xs) {
|
||||
return (xs = xs - T{1});
|
||||
}
|
||||
|
||||
// operator++
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
constexpr vec<T, Size> operator++(vec<T, Size>& xs, int) {
|
||||
vec<T, Size> ys = xs;
|
||||
++xs;
|
||||
return ys;
|
||||
}
|
||||
|
||||
// operator--
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
constexpr vec<T, Size> operator--(vec<T, Size>& xs, int) {
|
||||
vec<T, Size> ys = xs;
|
||||
--xs;
|
||||
return ys;
|
||||
}
|
||||
|
||||
// operator+
|
||||
|
||||
template < typename T, typename U, std::size_t Size >
|
||||
|
||||
Reference in New Issue
Block a user