diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2022-01-11 21:20:11 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2022-01-11 21:20:11 +0300 |
commit | dff5c4800090a82bab95a787f90a3716900fbcbb (patch) | |
tree | 1c6576c65676d640ecc27769ea1c537c5e39f2b6 | |
parent | 679d9bef5b8117ced9bf37f99a4bc4ba37291ddf (diff) |
Fix type conversion error on MSVC (thanks @JacquesLucke for that)
-rw-r--r-- | source/blender/blenlib/BLI_math_vec_types.hh | 12 | ||||
-rw-r--r-- | source/blender/blenlib/BLI_utildefines.h | 2 |
2 files changed, 6 insertions, 8 deletions
diff --git a/source/blender/blenlib/BLI_math_vec_types.hh b/source/blender/blenlib/BLI_math_vec_types.hh index b00a39f15a4..fd95acbe6bc 100644 --- a/source/blender/blenlib/BLI_math_vec_types.hh +++ b/source/blender/blenlib/BLI_math_vec_types.hh @@ -172,14 +172,12 @@ template<typename T, int Size> struct vec_base : public vec_struct_base<T, Size> /** Masking. */ - template<BLI_ENABLE_IF_VEC(Size, >= 3)> explicit operator vec_base<T, 2>() const + template<typename U, int OtherSize, BLI_ENABLE_IF(OtherSize > Size)> + explicit vec_base(const vec_base<U, OtherSize> &other) { - return vec_base<T, 2>(UNPACK2(*this)); - } - - template<BLI_ENABLE_IF_VEC(Size, >= 4)> explicit operator vec_base<T, 3>() const - { - return vec_base<T, 3>(UNPACK3(*this)); + for (int i = 0; i < Size; i++) { + (*this)[i] = static_cast<T>(other[i]); + } } #undef BLI_ENABLE_IF_VEC diff --git a/source/blender/blenlib/BLI_utildefines.h b/source/blender/blenlib/BLI_utildefines.h index 9898796facc..9fe092fe525 100644 --- a/source/blender/blenlib/BLI_utildefines.h +++ b/source/blender/blenlib/BLI_utildefines.h @@ -847,7 +847,7 @@ extern bool BLI_memory_is_zero(const void *arr, const size_t arr_size); * \note Often one has to invoke this macro with double parenthesis. That's because the condition * often contains a comma and angle brackets are not recognized as parenthesis by the preprocessor. */ -#define BLI_ENABLE_IF(condition) typename std::enable_if_t<condition> * = nullptr +#define BLI_ENABLE_IF(condition) typename std::enable_if_t<(condition)> * = nullptr /** \} */ |