diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2022-01-10 22:11:54 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2022-01-10 22:11:54 +0300 |
commit | 3b6733c5048561d3fe0cd7cc1e8a24041d8207f5 (patch) | |
tree | 6f4a647b3088bdd0076d1e4d97f5c6d51a417a6f | |
parent | 243296db6a55d43e39a028a2478359de4dc18dab (diff) |
BLI_math_vec_types: Add bit shift operators
-rw-r--r-- | source/blender/blenlib/BLI_math_vec_types.hh | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_math_vec_types.hh b/source/blender/blenlib/BLI_math_vec_types.hh index ae8cb0056bb..2e0b17d8bc4 100644 --- a/source/blender/blenlib/BLI_math_vec_types.hh +++ b/source/blender/blenlib/BLI_math_vec_types.hh @@ -444,6 +444,48 @@ template<typename T, int Size> struct vec_base : public vec_struct_base<T, Size> BLI_VEC_OP_IMPL(ret, i, ret[i] = ~a[i]); } + /** Bit-shift operators. */ + + BLI_INT_OP(T) friend vec_base operator<<(const vec_base &a, const vec_base &b) + { + BLI_VEC_OP_IMPL(ret, i, ret[i] = a[i] << b[i]); + } + + BLI_INT_OP(T) friend vec_base operator<<(const vec_base &a, T b) + { + BLI_VEC_OP_IMPL(ret, i, ret[i] = a[i] << b); + } + + BLI_INT_OP(T) vec_base &operator<<=(T b) + { + BLI_VEC_OP_IMPL_SELF(i, (*this)[i] <<= b); + } + + BLI_INT_OP(T) vec_base &operator<<=(const vec_base &b) + { + BLI_VEC_OP_IMPL_SELF(i, (*this)[i] <<= b[i]); + } + + BLI_INT_OP(T) friend vec_base operator>>(const vec_base &a, const vec_base &b) + { + BLI_VEC_OP_IMPL(ret, i, ret[i] = a[i] >> b[i]); + } + + BLI_INT_OP(T) friend vec_base operator>>(const vec_base &a, T b) + { + BLI_VEC_OP_IMPL(ret, i, ret[i] = a[i] >> b); + } + + BLI_INT_OP(T) vec_base &operator>>=(T b) + { + BLI_VEC_OP_IMPL_SELF(i, (*this)[i] >>= b); + } + + BLI_INT_OP(T) vec_base &operator>>=(const vec_base &b) + { + BLI_VEC_OP_IMPL_SELF(i, (*this)[i] >>= b[i]); + } + /** Modulo operators. */ BLI_INT_OP(T) friend vec_base operator%(const vec_base &a, const vec_base &b) |