Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2022-01-11 21:20:11 +0300
committerClément Foucault <foucault.clem@gmail.com>2022-01-11 21:20:11 +0300
commitdff5c4800090a82bab95a787f90a3716900fbcbb (patch)
tree1c6576c65676d640ecc27769ea1c537c5e39f2b6
parent679d9bef5b8117ced9bf37f99a4bc4ba37291ddf (diff)
Fix type conversion error on MSVC (thanks @JacquesLucke for that)
-rw-r--r--source/blender/blenlib/BLI_math_vec_types.hh12
-rw-r--r--source/blender/blenlib/BLI_utildefines.h2
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
/** \} */