From f7e2559fd649610881b1749b6d30cc2ba9fcbdb6 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Mon, 28 Jun 2021 13:10:48 +0200 Subject: BLI: improve enum operators * Use unsigned integer types for bit operations. * Use 64 bit integer instead of 32 bit. * Support scoped enumes (aka `enum class`) by adding some more casts. --- source/blender/blenlib/BLI_utildefines.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'source') diff --git a/source/blender/blenlib/BLI_utildefines.h b/source/blender/blenlib/BLI_utildefines.h index 0ddabcaa2fb..5b84e050f82 100644 --- a/source/blender/blenlib/BLI_utildefines.h +++ b/source/blender/blenlib/BLI_utildefines.h @@ -788,23 +788,24 @@ extern bool BLI_memory_is_zero(const void *arr, const size_t arr_size); extern "C++" { \ inline constexpr _enum_type operator|(_enum_type a, _enum_type b) \ { \ - return static_cast<_enum_type>(static_cast(a) | b); \ + return static_cast<_enum_type>(static_cast(a) | static_cast(b)); \ } \ inline constexpr _enum_type operator&(_enum_type a, _enum_type b) \ { \ - return static_cast<_enum_type>(static_cast(a) & b); \ + return static_cast<_enum_type>(static_cast(a) & static_cast(b)); \ } \ inline constexpr _enum_type operator~(_enum_type a) \ { \ - return static_cast<_enum_type>(~static_cast(a) & (2 * _max_enum_value - 1)); \ + return static_cast<_enum_type>(~static_cast(a) & \ + (2 * static_cast(_max_enum_value) - 1)); \ } \ inline _enum_type &operator|=(_enum_type &a, _enum_type b) \ { \ - return a = static_cast<_enum_type>(static_cast(a) | b); \ + return a = static_cast<_enum_type>(static_cast(a) | static_cast(b)); \ } \ inline _enum_type &operator&=(_enum_type &a, _enum_type b) \ { \ - return a = static_cast<_enum_type>(static_cast(a) & b); \ + return a = static_cast<_enum_type>(static_cast(a) & static_cast(b)); \ } \ } /* extern "C++" */ -- cgit v1.2.3