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:
authorJacques Lucke <jacques@blender.org>2022-09-25 18:39:45 +0300
committerJacques Lucke <jacques@blender.org>2022-09-25 18:39:45 +0300
commitc6e70e7bacf82b38ca7125d6821713a711489c0b (patch)
tree3679590f6254b7fbbd6623080edafe217f20c7b6 /source/blender/blenlib
parent0419ee871ff960f62e28a2a9fed764f66c616d71 (diff)
Cleanup: follow C++ type cast style guide in some files
https://wiki.blender.org/wiki/Style_Guide/C_Cpp#C.2B.2B_Type_Cast This was discussed in https://devtalk.blender.org/t/rfc-style-guide-for-type-casts-in-c-code/25907.
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r--source/blender/blenlib/BLI_allocator.hh9
-rw-r--r--source/blender/blenlib/BLI_any.hh9
-rw-r--r--source/blender/blenlib/BLI_array.hh3
-rw-r--r--source/blender/blenlib/BLI_bit_vector.hh8
-rw-r--r--source/blender/blenlib/BLI_cpp_type_make.hh6
-rw-r--r--source/blender/blenlib/BLI_function_ref.hh2
-rw-r--r--source/blender/blenlib/BLI_generic_array.hh2
-rw-r--r--source/blender/blenlib/BLI_generic_virtual_array.hh32
-rw-r--r--source/blender/blenlib/BLI_hash.hh10
-rw-r--r--source/blender/blenlib/BLI_hash_tables.hh12
-rw-r--r--source/blender/blenlib/BLI_linear_allocator.hh2
-rw-r--r--source/blender/blenlib/BLI_map.hh6
-rw-r--r--source/blender/blenlib/BLI_math_vec_types.hh39
-rw-r--r--source/blender/blenlib/BLI_math_vector.hh6
-rw-r--r--source/blender/blenlib/BLI_memory_utils.hh2
-rw-r--r--source/blender/blenlib/BLI_mesh_intersect.hh12
-rw-r--r--source/blender/blenlib/BLI_probing_strategies.hh2
-rw-r--r--source/blender/blenlib/BLI_rand.hh8
-rw-r--r--source/blender/blenlib/BLI_resource_scope.hh2
-rw-r--r--source/blender/blenlib/BLI_set.hh4
-rw-r--r--source/blender/blenlib/BLI_span.hh8
-rw-r--r--source/blender/blenlib/BLI_string_ref.hh52
-rw-r--r--source/blender/blenlib/BLI_utildefines.h11
-rw-r--r--source/blender/blenlib/BLI_vector.hh13
-rw-r--r--source/blender/blenlib/BLI_vector_set.hh6
-rw-r--r--source/blender/blenlib/BLI_virtual_array.hh2
-rw-r--r--source/blender/blenlib/tests/BLI_linear_allocator_test.cc2
-rw-r--r--source/blender/blenlib/tests/BLI_span_test.cc2
-rw-r--r--source/blender/blenlib/tests/BLI_stack_cxx_test.cc8
-rw-r--r--source/blender/blenlib/tests/BLI_string_ref_test.cc2
30 files changed, 129 insertions, 153 deletions
diff --git a/source/blender/blenlib/BLI_allocator.hh b/source/blender/blenlib/BLI_allocator.hh
index f19292fffd8..149dda5a50e 100644
--- a/source/blender/blenlib/BLI_allocator.hh
+++ b/source/blender/blenlib/BLI_allocator.hh
@@ -65,13 +65,12 @@ class RawAllocator {
public:
void *allocate(size_t size, size_t alignment, const char *UNUSED(name))
{
- BLI_assert(is_power_of_2_i(static_cast<int>(alignment)));
+ BLI_assert(is_power_of_2_i(int(alignment)));
void *ptr = malloc(size + alignment + sizeof(MemHead));
void *used_ptr = reinterpret_cast<void *>(
- reinterpret_cast<uintptr_t>(POINTER_OFFSET(ptr, alignment + sizeof(MemHead))) &
- ~(static_cast<uintptr_t>(alignment) - 1));
- int offset = static_cast<int>((intptr_t)used_ptr - (intptr_t)ptr);
- BLI_assert(offset >= static_cast<int>(sizeof(MemHead)));
+ uintptr_t(POINTER_OFFSET(ptr, alignment + sizeof(MemHead))) & ~(uintptr_t(alignment) - 1));
+ int offset = int(intptr_t(used_ptr) - intptr_t(ptr));
+ BLI_assert(offset >= int(sizeof(MemHead)));
(static_cast<MemHead *>(used_ptr) - 1)->offset = offset;
return used_ptr;
}
diff --git a/source/blender/blenlib/BLI_any.hh b/source/blender/blenlib/BLI_any.hh
index f9b53436763..df67a090e92 100644
--- a/source/blender/blenlib/BLI_any.hh
+++ b/source/blender/blenlib/BLI_any.hh
@@ -42,12 +42,13 @@ template<typename ExtraInfo, typename T>
inline constexpr AnyTypeInfo<ExtraInfo> info_for_inline = {
is_trivially_copy_constructible_extended_v<T> ?
nullptr :
- +[](void *dst, const void *src) { new (dst) T(*(const T *)src); },
+ +[](void *dst, const void *src) { new (dst) T(*static_cast<const T *>(src)); },
is_trivially_move_constructible_extended_v<T> ?
nullptr :
- +[](void *dst, void *src) { new (dst) T(std::move(*(T *)src)); },
- is_trivially_destructible_extended_v<T> ? nullptr :
- +[](void *src) { std::destroy_at(((T *)src)); },
+ +[](void *dst, void *src) { new (dst) T(std::move(*static_cast<T *>(src))); },
+ is_trivially_destructible_extended_v<T> ?
+ nullptr :
+ +[](void *src) { std::destroy_at((static_cast<T *>(src))); },
nullptr,
ExtraInfo::template get<T>()};
diff --git a/source/blender/blenlib/BLI_array.hh b/source/blender/blenlib/BLI_array.hh
index 813277d9968..200381048c9 100644
--- a/source/blender/blenlib/BLI_array.hh
+++ b/source/blender/blenlib/BLI_array.hh
@@ -424,8 +424,7 @@ class Array {
T *allocate(int64_t size)
{
- return static_cast<T *>(
- allocator_.allocate(static_cast<size_t>(size) * sizeof(T), alignof(T), AT));
+ return static_cast<T *>(allocator_.allocate(size_t(size) * sizeof(T), alignof(T), AT));
}
void deallocate_if_not_inline(T *ptr)
diff --git a/source/blender/blenlib/BLI_bit_vector.hh b/source/blender/blenlib/BLI_bit_vector.hh
index 2cec190f84a..ca6c6b2cd2a 100644
--- a/source/blender/blenlib/BLI_bit_vector.hh
+++ b/source/blender/blenlib/BLI_bit_vector.hh
@@ -106,7 +106,7 @@ class MutableBitRef {
MutableBitRef(uint8_t *byte_ptr, const int64_t bit_index)
{
byte_ptr_ = byte_ptr + (bit_index >> 3);
- mask_ = 1 << static_cast<uint8_t>(bit_index & 7);
+ mask_ = 1 << uint8_t(bit_index & 7);
}
/**
@@ -211,7 +211,7 @@ class BitVector {
data_ = inline_buffer_;
size_in_bits_ = 0;
capacity_in_bits_ = BitsInInlineBuffer;
- uninitialized_fill_n(data_, BytesInInlineBuffer, static_cast<uint8_t>(0));
+ uninitialized_fill_n(data_, BytesInInlineBuffer, uint8_t(0));
}
BitVector(NoExceptConstructor, Allocator allocator = {}) noexcept : BitVector(allocator)
@@ -447,7 +447,7 @@ class BitVector {
/* Fill entire bytes at once. */
const int64_t start_fill_byte_index = aligned_ranges.aligned.start() / BitsPerByte;
const int64_t bytes_to_fill = aligned_ranges.aligned.size() / BitsPerByte;
- const uint8_t fill_value = value ? (uint8_t)0xff : (uint8_t)0x00;
+ const uint8_t fill_value = value ? uint8_t(0xff) : uint8_t(0x00);
initialized_fill_n(data_ + start_fill_byte_index, bytes_to_fill, fill_value);
/* Fill bits in the end that don't cover a full byte. */
@@ -505,7 +505,7 @@ class BitVector {
* uninitialized byte. */
uninitialized_fill_n(new_data + bytes_to_copy,
new_capacity_in_bytes - bytes_to_copy,
- (uint8_t)initial_value_for_new_bytes);
+ uint8_t(initial_value_for_new_bytes));
if (!this->is_inline()) {
allocator_.deallocate(data_);
diff --git a/source/blender/blenlib/BLI_cpp_type_make.hh b/source/blender/blenlib/BLI_cpp_type_make.hh
index b0dbbff7ca8..3acef4b0f09 100644
--- a/source/blender/blenlib/BLI_cpp_type_make.hh
+++ b/source/blender/blenlib/BLI_cpp_type_make.hh
@@ -211,8 +211,8 @@ CPPType::CPPType(CPPTypeParam<T, Flags> /* unused */, StringRef debug_name)
using namespace cpp_type_util;
debug_name_ = debug_name;
- size_ = (int64_t)sizeof(T);
- alignment_ = (int64_t)alignof(T);
+ size_ = int64_t(sizeof(T));
+ alignment_ = int64_t(alignof(T));
is_trivial_ = std::is_trivial_v<T>;
is_trivially_destructible_ = std::is_trivially_destructible_v<T>;
if constexpr (std::is_default_constructible_v<T>) {
@@ -221,7 +221,7 @@ CPPType::CPPType(CPPTypeParam<T, Flags> /* unused */, StringRef debug_name)
value_initialize_ = value_initialize_cb<T>;
value_initialize_indices_ = value_initialize_indices_cb<T>;
static T default_value;
- default_value_ = (void *)&default_value;
+ default_value_ = &default_value;
}
if constexpr (std::is_destructible_v<T>) {
destruct_ = destruct_cb<T>;
diff --git a/source/blender/blenlib/BLI_function_ref.hh b/source/blender/blenlib/BLI_function_ref.hh
index 9a38176c988..bc386322c5d 100644
--- a/source/blender/blenlib/BLI_function_ref.hh
+++ b/source/blender/blenlib/BLI_function_ref.hh
@@ -116,7 +116,7 @@ template<typename Ret, typename... Params> class FunctionRef<Ret(Params...)> {
!std::is_same_v<std::remove_cv_t<std::remove_reference_t<Callable>>, FunctionRef>))>
FunctionRef(Callable &&callable)
: callback_(callback_fn<typename std::remove_reference_t<Callable>>),
- callable_(reinterpret_cast<intptr_t>(&callable))
+ callable_(intptr_t(&callable))
{
}
diff --git a/source/blender/blenlib/BLI_generic_array.hh b/source/blender/blenlib/BLI_generic_array.hh
index 4b917434264..f0eddd30419 100644
--- a/source/blender/blenlib/BLI_generic_array.hh
+++ b/source/blender/blenlib/BLI_generic_array.hh
@@ -243,7 +243,7 @@ class GArray {
{
const int64_t item_size = type_->size();
const int64_t alignment = type_->alignment();
- return allocator_.allocate(static_cast<size_t>(size) * item_size, alignment, AT);
+ return allocator_.allocate(size_t(size) * item_size, alignment, AT);
}
void deallocate(void *ptr)
diff --git a/source/blender/blenlib/BLI_generic_virtual_array.hh b/source/blender/blenlib/BLI_generic_virtual_array.hh
index 21549896f45..9545eaf9622 100644
--- a/source/blender/blenlib/BLI_generic_virtual_array.hh
+++ b/source/blender/blenlib/BLI_generic_virtual_array.hh
@@ -315,7 +315,7 @@ template<typename T> class GVArrayImpl_For_VArray : public GVArrayImpl {
protected:
void get(const int64_t index, void *r_value) const override
{
- *(T *)r_value = varray_[index];
+ *static_cast<T *>(r_value) = varray_[index];
}
void get_to_uninitialized(const int64_t index, void *r_value) const override
@@ -325,22 +325,24 @@ template<typename T> class GVArrayImpl_For_VArray : public GVArrayImpl {
void materialize(const IndexMask mask, void *dst) const override
{
- varray_.materialize(mask, MutableSpan((T *)dst, mask.min_array_size()));
+ varray_.materialize(mask, MutableSpan(static_cast<T *>(dst), mask.min_array_size()));
}
void materialize_to_uninitialized(const IndexMask mask, void *dst) const override
{
- varray_.materialize_to_uninitialized(mask, MutableSpan((T *)dst, mask.min_array_size()));
+ varray_.materialize_to_uninitialized(
+ mask, MutableSpan(static_cast<T *>(dst), mask.min_array_size()));
}
void materialize_compressed(const IndexMask mask, void *dst) const override
{
- varray_.materialize_compressed(mask, MutableSpan((T *)dst, mask.size()));
+ varray_.materialize_compressed(mask, MutableSpan(static_cast<T *>(dst), mask.size()));
}
void materialize_compressed_to_uninitialized(const IndexMask mask, void *dst) const override
{
- varray_.materialize_compressed_to_uninitialized(mask, MutableSpan((T *)dst, mask.size()));
+ varray_.materialize_compressed_to_uninitialized(
+ mask, MutableSpan(static_cast<T *>(dst), mask.size()));
}
bool try_assign_VArray(void *varray) const override
@@ -422,7 +424,7 @@ template<typename T> class GVMutableArrayImpl_For_VMutableArray : public GVMutab
protected:
void get(const int64_t index, void *r_value) const override
{
- *(T *)r_value = varray_[index];
+ *static_cast<T *>(r_value) = varray_[index];
}
void get_to_uninitialized(const int64_t index, void *r_value) const override
@@ -443,40 +445,42 @@ template<typename T> class GVMutableArrayImpl_For_VMutableArray : public GVMutab
void set_by_relocate(const int64_t index, void *value) override
{
- T &value_ = *(T *)value;
+ T &value_ = *static_cast<T *>(value);
varray_.set(index, std::move(value_));
value_.~T();
}
void set_by_move(const int64_t index, void *value) override
{
- T &value_ = *(T *)value;
+ T &value_ = *static_cast<T *>(value);
varray_.set(index, std::move(value_));
}
void set_all(const void *src) override
{
- varray_.set_all(Span((T *)src, size_));
+ varray_.set_all(Span(static_cast<const T *>(src), size_));
}
void materialize(const IndexMask mask, void *dst) const override
{
- varray_.materialize(mask, MutableSpan((T *)dst, mask.min_array_size()));
+ varray_.materialize(mask, MutableSpan(static_cast<T *>(dst), mask.min_array_size()));
}
void materialize_to_uninitialized(const IndexMask mask, void *dst) const override
{
- varray_.materialize_to_uninitialized(mask, MutableSpan((T *)dst, mask.min_array_size()));
+ varray_.materialize_to_uninitialized(
+ mask, MutableSpan(static_cast<T *>(dst), mask.min_array_size()));
}
void materialize_compressed(const IndexMask mask, void *dst) const override
{
- varray_.materialize_compressed(mask, MutableSpan((T *)dst, mask.size()));
+ varray_.materialize_compressed(mask, MutableSpan(static_cast<T *>(dst), mask.size()));
}
void materialize_compressed_to_uninitialized(const IndexMask mask, void *dst) const override
{
- varray_.materialize_compressed_to_uninitialized(mask, MutableSpan((T *)dst, mask.size()));
+ varray_.materialize_compressed_to_uninitialized(
+ mask, MutableSpan(static_cast<T *>(dst), mask.size()));
}
bool try_assign_VArray(void *varray) const override
@@ -709,7 +713,7 @@ inline bool GVMutableArray::try_assign_VMutableArray(VMutableArray<T> &varray) c
inline GVMutableArrayImpl *GVMutableArray::get_impl() const
{
- return (GVMutableArrayImpl *)impl_;
+ return const_cast<GVMutableArrayImpl *>(static_cast<const GVMutableArrayImpl *>(impl_));
}
/** \} */
diff --git a/source/blender/blenlib/BLI_hash.hh b/source/blender/blenlib/BLI_hash.hh
index 25d7cd6aaf8..693d4a8a71c 100644
--- a/source/blender/blenlib/BLI_hash.hh
+++ b/source/blender/blenlib/BLI_hash.hh
@@ -85,7 +85,7 @@ template<typename T> struct DefaultHash {
{
if constexpr (std::is_enum_v<T>) {
/* For enums use the value as hash directly. */
- return (uint64_t)value;
+ return uint64_t(value);
}
else {
/* Try to call the `hash()` function on the value. */
@@ -119,7 +119,7 @@ template<typename T> struct DefaultHash<const T> {
template<> struct DefaultHash<TYPE> { \
uint64_t operator()(TYPE value) const \
{ \
- return static_cast<uint64_t>(value); \
+ return uint64_t(value); \
} \
}
@@ -158,7 +158,7 @@ template<> struct DefaultHash<double> {
template<> struct DefaultHash<bool> {
uint64_t operator()(bool value) const
{
- return static_cast<uint64_t>((value != false) * 1298191);
+ return uint64_t((value != false) * 1298191);
}
};
@@ -209,8 +209,8 @@ template<> struct DefaultHash<std::string_view> {
template<typename T> struct DefaultHash<T *> {
uint64_t operator()(const T *value) const
{
- uintptr_t ptr = reinterpret_cast<uintptr_t>(value);
- uint64_t hash = static_cast<uint64_t>(ptr >> 4);
+ uintptr_t ptr = uintptr_t(value);
+ uint64_t hash = uint64_t(ptr >> 4);
return hash;
}
};
diff --git a/source/blender/blenlib/BLI_hash_tables.hh b/source/blender/blenlib/BLI_hash_tables.hh
index 156fe481828..85a8fd5d385 100644
--- a/source/blender/blenlib/BLI_hash_tables.hh
+++ b/source/blender/blenlib/BLI_hash_tables.hh
@@ -43,8 +43,7 @@ inline constexpr int64_t log2_floor_constexpr(const int64_t x)
inline constexpr int64_t log2_ceil_constexpr(const int64_t x)
{
BLI_assert(x >= 0);
- return (is_power_of_2_constexpr(static_cast<int>(x))) ? log2_floor_constexpr(x) :
- log2_floor_constexpr(x) + 1;
+ return (is_power_of_2_constexpr(int(x))) ? log2_floor_constexpr(x) : log2_floor_constexpr(x) + 1;
}
inline constexpr int64_t power_of_2_max_constexpr(const int64_t x)
@@ -71,17 +70,14 @@ inline constexpr int64_t ceil_division_by_fraction(const int64_t x,
const int64_t numerator,
const int64_t denominator)
{
- return static_cast<int64_t>(
- ceil_division(static_cast<uint64_t>(x) * static_cast<uint64_t>(denominator),
- static_cast<uint64_t>(numerator)));
+ return int64_t(ceil_division(uint64_t(x) * uint64_t(denominator), uint64_t(numerator)));
}
inline constexpr int64_t floor_multiplication_with_fraction(const int64_t x,
const int64_t numerator,
const int64_t denominator)
{
- return static_cast<int64_t>((static_cast<uint64_t>(x) * static_cast<uint64_t>(numerator) /
- static_cast<uint64_t>(denominator)));
+ return int64_t((uint64_t(x) * uint64_t(numerator) / uint64_t(denominator)));
}
inline constexpr int64_t total_slot_amount_for_usable_slots(
@@ -121,7 +117,7 @@ class LoadFactor {
int64_t *r_total_slots,
int64_t *r_usable_slots) const
{
- BLI_assert(is_power_of_2_i(static_cast<int>(min_total_slots)));
+ BLI_assert(is_power_of_2_i(int(min_total_slots)));
int64_t total_slots = this->compute_total_slots(min_usable_slots, numerator_, denominator_);
total_slots = std::max(total_slots, min_total_slots);
diff --git a/source/blender/blenlib/BLI_linear_allocator.hh b/source/blender/blenlib/BLI_linear_allocator.hh
index deb6ea3b5fd..07211de3aed 100644
--- a/source/blender/blenlib/BLI_linear_allocator.hh
+++ b/source/blender/blenlib/BLI_linear_allocator.hh
@@ -161,7 +161,7 @@ template<typename Allocator = GuardedAllocator> class LinearAllocator : NonCopya
void *pointer_buffer = this->allocate(element_amount * sizeof(void *), alignof(void *));
void *elements_buffer = this->allocate(element_amount * element_size, element_alignment);
- MutableSpan<void *> pointers((void **)pointer_buffer, element_amount);
+ MutableSpan<void *> pointers(static_cast<void **>(pointer_buffer), element_amount);
void *next_element_buffer = elements_buffer;
for (int64_t i : IndexRange(element_amount)) {
pointers[i] = next_element_buffer;
diff --git a/source/blender/blenlib/BLI_map.hh b/source/blender/blenlib/BLI_map.hh
index 95d1e344894..4322e3c0f2d 100644
--- a/source/blender/blenlib/BLI_map.hh
+++ b/source/blender/blenlib/BLI_map.hh
@@ -943,7 +943,7 @@ class Map {
*/
int64_t size_in_bytes() const
{
- return static_cast<int64_t>(sizeof(Slot) * slots_.size());
+ return int64_t(sizeof(Slot) * slots_.size());
}
/**
@@ -987,7 +987,7 @@ class Map {
max_load_factor_.compute_total_and_usable_slots(
SlotArray::inline_buffer_capacity(), min_usable_slots, &total_slots, &usable_slots);
BLI_assert(total_slots >= 1);
- const uint64_t new_slot_mask = static_cast<uint64_t>(total_slots) - 1;
+ const uint64_t new_slot_mask = uint64_t(total_slots) - 1;
/**
* Optimize the case when the map was empty beforehand. We can avoid some copies here.
@@ -1261,7 +1261,7 @@ template<typename Key, typename Value> class StdUnorderedMapWrapper {
public:
int64_t size() const
{
- return static_cast<int64_t>(map_.size());
+ return int64_t(map_.size());
}
bool is_empty() const
diff --git a/source/blender/blenlib/BLI_math_vec_types.hh b/source/blender/blenlib/BLI_math_vec_types.hh
index 7f20881dfa3..c19317867a9 100644
--- a/source/blender/blenlib/BLI_math_vec_types.hh
+++ b/source/blender/blenlib/BLI_math_vec_types.hh
@@ -74,28 +74,28 @@ template<typename T, int Size> struct vec_base : public vec_struct_base<T, Size>
explicit vec_base(uint value)
{
for (int i = 0; i < Size; i++) {
- (*this)[i] = static_cast<T>(value);
+ (*this)[i] = T(value);
}
}
explicit vec_base(int value)
{
for (int i = 0; i < Size; i++) {
- (*this)[i] = static_cast<T>(value);
+ (*this)[i] = T(value);
}
}
explicit vec_base(float value)
{
for (int i = 0; i < Size; i++) {
- (*this)[i] = static_cast<T>(value);
+ (*this)[i] = T(value);
}
}
explicit vec_base(double value)
{
for (int i = 0; i < Size; i++) {
- (*this)[i] = static_cast<T>(value);
+ (*this)[i] = T(value);
}
}
@@ -126,53 +126,42 @@ template<typename T, int Size> struct vec_base : public vec_struct_base<T, Size>
/** Mixed scalar-vector constructors. */
template<typename U, BLI_ENABLE_IF_VEC(Size, == 3)>
- constexpr vec_base(const vec_base<U, 2> &xy, T z)
- : vec_base(static_cast<T>(xy.x), static_cast<T>(xy.y), z)
+ constexpr vec_base(const vec_base<U, 2> &xy, T z) : vec_base(T(xy.x), T(xy.y), z)
{
}
template<typename U, BLI_ENABLE_IF_VEC(Size, == 3)>
- constexpr vec_base(T x, const vec_base<U, 2> &yz)
- : vec_base(x, static_cast<T>(yz.x), static_cast<T>(yz.y))
+ constexpr vec_base(T x, const vec_base<U, 2> &yz) : vec_base(x, T(yz.x), T(yz.y))
{
}
template<typename U, BLI_ENABLE_IF_VEC(Size, == 4)>
- vec_base(vec_base<U, 3> xyz, T w)
- : vec_base(
- static_cast<T>(xyz.x), static_cast<T>(xyz.y), static_cast<T>(xyz.z), static_cast<T>(w))
+ vec_base(vec_base<U, 3> xyz, T w) : vec_base(T(xyz.x), T(xyz.y), T(xyz.z), T(w))
{
}
template<typename U, BLI_ENABLE_IF_VEC(Size, == 4)>
- vec_base(T x, vec_base<U, 3> yzw)
- : vec_base(
- static_cast<T>(x), static_cast<T>(yzw.x), static_cast<T>(yzw.y), static_cast<T>(yzw.z))
+ vec_base(T x, vec_base<U, 3> yzw) : vec_base(T(x), T(yzw.x), T(yzw.y), T(yzw.z))
{
}
template<typename U, typename V, BLI_ENABLE_IF_VEC(Size, == 4)>
- vec_base(vec_base<U, 2> xy, vec_base<V, 2> zw)
- : vec_base(
- static_cast<T>(xy.x), static_cast<T>(xy.y), static_cast<T>(zw.x), static_cast<T>(zw.y))
+ vec_base(vec_base<U, 2> xy, vec_base<V, 2> zw) : vec_base(T(xy.x), T(xy.y), T(zw.x), T(zw.y))
{
}
template<typename U, BLI_ENABLE_IF_VEC(Size, == 4)>
- vec_base(vec_base<U, 2> xy, T z, T w)
- : vec_base(static_cast<T>(xy.x), static_cast<T>(xy.y), static_cast<T>(z), static_cast<T>(w))
+ vec_base(vec_base<U, 2> xy, T z, T w) : vec_base(T(xy.x), T(xy.y), T(z), T(w))
{
}
template<typename U, BLI_ENABLE_IF_VEC(Size, == 4)>
- vec_base(T x, vec_base<U, 2> yz, T w)
- : vec_base(static_cast<T>(x), static_cast<T>(yz.x), static_cast<T>(yz.y), static_cast<T>(w))
+ vec_base(T x, vec_base<U, 2> yz, T w) : vec_base(T(x), T(yz.x), T(yz.y), T(w))
{
}
template<typename U, BLI_ENABLE_IF_VEC(Size, == 4)>
- vec_base(T x, T y, vec_base<U, 2> zw)
- : vec_base(static_cast<T>(x), static_cast<T>(y), static_cast<T>(zw.x), static_cast<T>(zw.y))
+ vec_base(T x, T y, vec_base<U, 2> zw) : vec_base(T(x), T(y), T(zw.x), T(zw.y))
{
}
@@ -182,7 +171,7 @@ template<typename T, int Size> struct vec_base : public vec_struct_base<T, Size>
explicit vec_base(const vec_base<U, OtherSize> &other)
{
for (int i = 0; i < Size; i++) {
- (*this)[i] = static_cast<T>(other[i]);
+ (*this)[i] = T(other[i]);
}
}
@@ -214,7 +203,7 @@ template<typename T, int Size> struct vec_base : public vec_struct_base<T, Size>
template<typename U> explicit vec_base(const vec_base<U, Size> &vec)
{
for (int i = 0; i < Size; i++) {
- (*this)[i] = static_cast<T>(vec[i]);
+ (*this)[i] = T(vec[i]);
}
}
diff --git a/source/blender/blenlib/BLI_math_vector.hh b/source/blender/blenlib/BLI_math_vector.hh
index 384c4b49070..3067232e8ea 100644
--- a/source/blender/blenlib/BLI_math_vector.hh
+++ b/source/blender/blenlib/BLI_math_vector.hh
@@ -357,9 +357,9 @@ inline vec_base<T, 3> cross(const vec_base<T, 3> &a, const vec_base<T, 3> &b)
inline vec_base<float, 3> cross_high_precision(const vec_base<float, 3> &a,
const vec_base<float, 3> &b)
{
- return {(float)((double)a.y * b.z - (double)a.z * b.y),
- (float)((double)a.z * b.x - (double)a.x * b.z),
- (float)((double)a.x * b.y - (double)a.y * b.x)};
+ return {float(double(a.y) * double(b.z) - double(a.z) * double(b.y)),
+ float(double(a.z) * double(b.x) - double(a.x) * double(b.z)),
+ float(double(a.x) * double(b.y) - double(a.y) * double(b.x))};
}
template<typename T, BLI_ENABLE_IF((is_math_float_type<T>))>
diff --git a/source/blender/blenlib/BLI_memory_utils.hh b/source/blender/blenlib/BLI_memory_utils.hh
index c2ad3ea761a..0809f372b25 100644
--- a/source/blender/blenlib/BLI_memory_utils.hh
+++ b/source/blender/blenlib/BLI_memory_utils.hh
@@ -516,7 +516,7 @@ inline constexpr bool is_same_any_v = (std::is_same_v<T, Args> || ...);
*/
inline constexpr int64_t default_inline_buffer_capacity(size_t element_size)
{
- return (static_cast<int64_t>(element_size) < 100) ? 4 : 0;
+ return (int64_t(element_size) < 100) ? 4 : 0;
}
/**
diff --git a/source/blender/blenlib/BLI_mesh_intersect.hh b/source/blender/blenlib/BLI_mesh_intersect.hh
index 22ea83760aa..4ed1fe5f513 100644
--- a/source/blender/blenlib/BLI_mesh_intersect.hh
+++ b/source/blender/blenlib/BLI_mesh_intersect.hh
@@ -354,12 +354,12 @@ struct BoundingBox {
void combine(const double3 &p)
{
- min.x = min_ff(min.x, static_cast<float>(p.x));
- min.y = min_ff(min.y, static_cast<float>(p.y));
- min.z = min_ff(min.z, static_cast<float>(p.z));
- max.x = max_ff(max.x, static_cast<float>(p.x));
- max.y = max_ff(max.y, static_cast<float>(p.y));
- max.z = max_ff(max.z, static_cast<float>(p.z));
+ min.x = min_ff(min.x, float(p.x));
+ min.y = min_ff(min.y, float(p.y));
+ min.z = min_ff(min.z, float(p.z));
+ max.x = max_ff(max.x, float(p.x));
+ max.y = max_ff(max.y, float(p.y));
+ max.z = max_ff(max.z, float(p.z));
}
void combine(const BoundingBox &bb)
diff --git a/source/blender/blenlib/BLI_probing_strategies.hh b/source/blender/blenlib/BLI_probing_strategies.hh
index 2c001270495..d11bed9208e 100644
--- a/source/blender/blenlib/BLI_probing_strategies.hh
+++ b/source/blender/blenlib/BLI_probing_strategies.hh
@@ -223,7 +223,7 @@ using DefaultProbingStrategy = PythonProbingStrategy<>;
int64_t linear_offset = 0; \
uint64_t current_hash = probing_strategy.get(); \
do { \
- int64_t R_SLOT_INDEX = static_cast<int64_t>((current_hash + static_cast<uint64_t>(linear_offset)) & MASK);
+ int64_t R_SLOT_INDEX = int64_t((current_hash + uint64_t(linear_offset)) & MASK);
#define SLOT_PROBING_END() \
} while (++linear_offset < probing_strategy.linear_steps()); \
diff --git a/source/blender/blenlib/BLI_rand.hh b/source/blender/blenlib/BLI_rand.hh
index 2c4484bd63f..e4f35bef217 100644
--- a/source/blender/blenlib/BLI_rand.hh
+++ b/source/blender/blenlib/BLI_rand.hh
@@ -29,7 +29,7 @@ class RandomNumberGenerator {
void seed(uint32_t seed)
{
constexpr uint64_t lowseed = 0x330E;
- x_ = (static_cast<uint64_t>(seed) << 16) | lowseed;
+ x_ = (uint64_t(seed) << 16) | lowseed;
}
/**
@@ -40,13 +40,13 @@ class RandomNumberGenerator {
uint32_t get_uint32()
{
this->step();
- return static_cast<uint32_t>(x_ >> 17);
+ return uint32_t(x_ >> 17);
}
int32_t get_int32()
{
this->step();
- return static_cast<int32_t>(x_ >> 17);
+ return int32_t(x_ >> 17);
}
/**
@@ -63,7 +63,7 @@ class RandomNumberGenerator {
*/
double get_double()
{
- return (double)this->get_int32() / 0x80000000;
+ return double(this->get_int32()) / 0x80000000;
}
/**
diff --git a/source/blender/blenlib/BLI_resource_scope.hh b/source/blender/blenlib/BLI_resource_scope.hh
index 9826b694e16..d3f6d5e3f13 100644
--- a/source/blender/blenlib/BLI_resource_scope.hh
+++ b/source/blender/blenlib/BLI_resource_scope.hh
@@ -128,7 +128,7 @@ template<typename Func> inline void ResourceScope::add_destruct_call(Func func)
{
void *buffer = allocator_.allocate(sizeof(Func), alignof(Func));
new (buffer) Func(std::move(func));
- this->add(buffer, [](void *data) { (*(Func *)data)(); });
+ this->add(buffer, [](void *data) { (*static_cast<Func *>(data))(); });
}
/**
diff --git a/source/blender/blenlib/BLI_set.hh b/source/blender/blenlib/BLI_set.hh
index a1b6ad9754e..a5f62001798 100644
--- a/source/blender/blenlib/BLI_set.hh
+++ b/source/blender/blenlib/BLI_set.hh
@@ -626,7 +626,7 @@ class Set {
max_load_factor_.compute_total_and_usable_slots(
SlotArray::inline_buffer_capacity(), min_usable_slots, &total_slots, &usable_slots);
BLI_assert(total_slots >= 1);
- const uint64_t new_slot_mask = static_cast<uint64_t>(total_slots) - 1;
+ const uint64_t new_slot_mask = uint64_t(total_slots) - 1;
/**
* Optimize the case when the set was empty beforehand. We can avoid some copies here.
@@ -854,7 +854,7 @@ template<typename Key> class StdUnorderedSetWrapper {
public:
int64_t size() const
{
- return static_cast<int64_t>(set_.size());
+ return int64_t(set_.size());
}
bool is_empty() const
diff --git a/source/blender/blenlib/BLI_span.hh b/source/blender/blenlib/BLI_span.hh
index 0f3fcea1270..adfccd8d6fe 100644
--- a/source/blender/blenlib/BLI_span.hh
+++ b/source/blender/blenlib/BLI_span.hh
@@ -112,13 +112,11 @@ template<typename T> class Span {
* Span<int> span = {1, 2, 3, 4};
* call_function_with_array(span);
*/
- constexpr Span(const std::initializer_list<T> &list)
- : Span(list.begin(), static_cast<int64_t>(list.size()))
+ constexpr Span(const std::initializer_list<T> &list) : Span(list.begin(), int64_t(list.size()))
{
}
- constexpr Span(const std::vector<T> &vector)
- : Span(vector.data(), static_cast<int64_t>(vector.size()))
+ constexpr Span(const std::vector<T> &vector) : Span(vector.data(), int64_t(vector.size()))
{
}
@@ -718,7 +716,7 @@ template<typename T> class MutableSpan {
{
BLI_assert((size_ * sizeof(T)) % sizeof(NewT) == 0);
int64_t new_size = size_ * sizeof(T) / sizeof(NewT);
- return MutableSpan<NewT>((NewT *)data_, new_size);
+ return MutableSpan<NewT>(reinterpret_cast<NewT *>(data_), new_size);
}
};
diff --git a/source/blender/blenlib/BLI_string_ref.hh b/source/blender/blenlib/BLI_string_ref.hh
index 3823bd02630..b202769e3c3 100644
--- a/source/blender/blenlib/BLI_string_ref.hh
+++ b/source/blender/blenlib/BLI_string_ref.hh
@@ -178,12 +178,12 @@ constexpr StringRefBase::operator Span<char>() const
*/
inline StringRefBase::operator std::string() const
{
- return std::string(data_, static_cast<size_t>(size_));
+ return std::string(data_, size_t(size_));
}
constexpr StringRefBase::operator std::string_view() const
{
- return std::string_view(data_, static_cast<size_t>(size_));
+ return std::string_view(data_, size_t(size_));
}
constexpr const char *StringRefBase::begin() const
@@ -209,7 +209,7 @@ constexpr IndexRange StringRefBase::index_range() const
inline void StringRefBase::unsafe_copy(char *dst) const
{
if (size_ > 0) {
- memcpy(dst, data_, static_cast<size_t>(size_));
+ memcpy(dst, data_, size_t(size_));
}
dst[size_] = '\0';
}
@@ -308,86 +308,79 @@ constexpr int64_t index_or_npos_to_int64(size_t index)
if (index == std::string_view::npos) {
return StringRef::not_found;
}
- return static_cast<int64_t>(index);
+ return int64_t(index);
}
constexpr int64_t StringRefBase::find(char c, int64_t pos) const
{
BLI_assert(pos >= 0);
- return index_or_npos_to_int64(std::string_view(*this).find(c, static_cast<size_t>(pos)));
+ return index_or_npos_to_int64(std::string_view(*this).find(c, size_t(pos)));
}
constexpr int64_t StringRefBase::find(StringRef str, int64_t pos) const
{
BLI_assert(pos >= 0);
- return index_or_npos_to_int64(std::string_view(*this).find(str, static_cast<size_t>(pos)));
+ return index_or_npos_to_int64(std::string_view(*this).find(str, size_t(pos)));
}
constexpr int64_t StringRefBase::rfind(char c, int64_t pos) const
{
BLI_assert(pos >= 0);
- return index_or_npos_to_int64(std::string_view(*this).rfind(c, static_cast<size_t>(pos)));
+ return index_or_npos_to_int64(std::string_view(*this).rfind(c, size_t(pos)));
}
constexpr int64_t StringRefBase::rfind(StringRef str, int64_t pos) const
{
BLI_assert(pos >= 0);
- return index_or_npos_to_int64(std::string_view(*this).rfind(str, static_cast<size_t>(pos)));
+ return index_or_npos_to_int64(std::string_view(*this).rfind(str, size_t(pos)));
}
constexpr int64_t StringRefBase::find_first_of(StringRef chars, int64_t pos) const
{
BLI_assert(pos >= 0);
- return index_or_npos_to_int64(
- std::string_view(*this).find_first_of(chars, static_cast<size_t>(pos)));
+ return index_or_npos_to_int64(std::string_view(*this).find_first_of(chars, size_t(pos)));
}
constexpr int64_t StringRefBase::find_first_of(char c, int64_t pos) const
{
BLI_assert(pos >= 0);
- return index_or_npos_to_int64(
- std::string_view(*this).find_first_of(c, static_cast<size_t>(pos)));
+ return index_or_npos_to_int64(std::string_view(*this).find_first_of(c, size_t(pos)));
}
constexpr int64_t StringRefBase::find_last_of(StringRef chars, int64_t pos) const
{
BLI_assert(pos >= 0);
- return index_or_npos_to_int64(
- std::string_view(*this).find_last_of(chars, static_cast<size_t>(pos)));
+ return index_or_npos_to_int64(std::string_view(*this).find_last_of(chars, size_t(pos)));
}
constexpr int64_t StringRefBase::find_last_of(char c, int64_t pos) const
{
BLI_assert(pos >= 0);
- return index_or_npos_to_int64(std::string_view(*this).find_last_of(c, static_cast<size_t>(pos)));
+ return index_or_npos_to_int64(std::string_view(*this).find_last_of(c, size_t(pos)));
}
constexpr int64_t StringRefBase::find_first_not_of(StringRef chars, int64_t pos) const
{
BLI_assert(pos >= 0);
- return index_or_npos_to_int64(
- std::string_view(*this).find_first_not_of(chars, static_cast<size_t>(pos)));
+ return index_or_npos_to_int64(std::string_view(*this).find_first_not_of(chars, size_t(pos)));
}
constexpr int64_t StringRefBase::find_first_not_of(char c, int64_t pos) const
{
BLI_assert(pos >= 0);
- return index_or_npos_to_int64(
- std::string_view(*this).find_first_not_of(c, static_cast<size_t>(pos)));
+ return index_or_npos_to_int64(std::string_view(*this).find_first_not_of(c, size_t(pos)));
}
constexpr int64_t StringRefBase::find_last_not_of(StringRef chars, int64_t pos) const
{
BLI_assert(pos >= 0);
- return index_or_npos_to_int64(
- std::string_view(*this).find_last_not_of(chars, static_cast<size_t>(pos)));
+ return index_or_npos_to_int64(std::string_view(*this).find_last_not_of(chars, size_t(pos)));
}
constexpr int64_t StringRefBase::find_last_not_of(char c, int64_t pos) const
{
BLI_assert(pos >= 0);
- return index_or_npos_to_int64(
- std::string_view(*this).find_last_not_of(c, static_cast<size_t>(pos)));
+ return index_or_npos_to_int64(std::string_view(*this).find_last_not_of(c, size_t(pos)));
}
constexpr StringRef StringRefBase::trim() const
@@ -440,15 +433,14 @@ constexpr StringRefNull::StringRefNull() : StringRefBase("", 0)
constexpr StringRefNull::StringRefNull(const char *str, const int64_t size)
: StringRefBase(str, size)
{
- BLI_assert(static_cast<int64_t>(strlen(str)) == size);
+ BLI_assert(int64_t(strlen(str)) == size);
}
/**
* Construct a StringRefNull from a null terminated c-string. The pointer must not point to
* NULL.
*/
-inline StringRefNull::StringRefNull(const char *str)
- : StringRefBase(str, static_cast<int64_t>(strlen(str)))
+inline StringRefNull::StringRefNull(const char *str) : StringRefBase(str, int64_t(strlen(str)))
{
BLI_assert(str != nullptr);
BLI_assert(data_[size_] == '\0');
@@ -504,7 +496,7 @@ constexpr StringRef::StringRef(StringRefNull other) : StringRefBase(other.data()
* Create a StringRef from a null-terminated c-string.
*/
constexpr StringRef::StringRef(const char *str)
- : StringRefBase(str, str ? static_cast<int64_t>(std::char_traits<char>::length(str)) : 0)
+ : StringRefBase(str, str ? int64_t(std::char_traits<char>::length(str)) : 0)
{
}
@@ -560,7 +552,7 @@ constexpr char StringRef::operator[](int64_t index) const
* second point points to a smaller address than the first one.
*/
constexpr StringRef::StringRef(const char *begin, const char *one_after_end)
- : StringRefBase(begin, static_cast<int64_t>(one_after_end - begin))
+ : StringRefBase(begin, int64_t(one_after_end - begin))
{
BLI_assert(begin <= one_after_end);
}
@@ -570,12 +562,12 @@ constexpr StringRef::StringRef(const char *begin, const char *one_after_end)
* will point to uninitialized memory.
*/
inline StringRef::StringRef(const std::string &str)
- : StringRefBase(str.data(), static_cast<int64_t>(str.size()))
+ : StringRefBase(str.data(), int64_t(str.size()))
{
}
constexpr StringRef::StringRef(std::string_view view)
- : StringRefBase(view.data(), static_cast<int64_t>(view.size()))
+ : StringRefBase(view.data(), int64_t(view.size()))
{
}
diff --git a/source/blender/blenlib/BLI_utildefines.h b/source/blender/blenlib/BLI_utildefines.h
index 9f68795a4a2..98177876f87 100644
--- a/source/blender/blenlib/BLI_utildefines.h
+++ b/source/blender/blenlib/BLI_utildefines.h
@@ -786,24 +786,23 @@ extern bool BLI_memory_is_zero(const void *arr, size_t arr_size);
extern "C++" { \
inline constexpr _enum_type operator|(_enum_type a, _enum_type b) \
{ \
- return static_cast<_enum_type>(static_cast<uint64_t>(a) | static_cast<uint64_t>(b)); \
+ return (_enum_type)(uint64_t(a) | uint64_t(b)); \
} \
inline constexpr _enum_type operator&(_enum_type a, _enum_type b) \
{ \
- return static_cast<_enum_type>(static_cast<uint64_t>(a) & static_cast<uint64_t>(b)); \
+ return (_enum_type)(uint64_t(a) & uint64_t(b)); \
} \
inline constexpr _enum_type operator~(_enum_type a) \
{ \
- return static_cast<_enum_type>(~static_cast<uint64_t>(a) & \
- (2 * static_cast<uint64_t>(_max_enum_value) - 1)); \
+ return (_enum_type)(~uint64_t(a) & (2 * uint64_t(_max_enum_value) - 1)); \
} \
inline _enum_type &operator|=(_enum_type &a, _enum_type b) \
{ \
- return a = static_cast<_enum_type>(static_cast<uint64_t>(a) | static_cast<uint64_t>(b)); \
+ return a = (_enum_type)(uint64_t(a) | uint64_t(b)); \
} \
inline _enum_type &operator&=(_enum_type &a, _enum_type b) \
{ \
- return a = static_cast<_enum_type>(static_cast<uint64_t>(a) & static_cast<uint64_t>(b)); \
+ return a = (_enum_type)(uint64_t(a) & uint64_t(b)); \
} \
} /* extern "C++" */
diff --git a/source/blender/blenlib/BLI_vector.hh b/source/blender/blenlib/BLI_vector.hh
index 1f5f97d754d..d07c9aeeb3d 100644
--- a/source/blender/blenlib/BLI_vector.hh
+++ b/source/blender/blenlib/BLI_vector.hh
@@ -96,8 +96,7 @@ class Vector {
*/
#ifndef NDEBUG
int64_t debug_size_;
-# define UPDATE_VECTOR_SIZE(ptr) \
- (ptr)->debug_size_ = static_cast<int64_t>((ptr)->end_ - (ptr)->begin_)
+# define UPDATE_VECTOR_SIZE(ptr) (ptr)->debug_size_ = int64_t((ptr)->end_ - (ptr)->begin_)
#else
# define UPDATE_VECTOR_SIZE(ptr) ((void)0)
#endif
@@ -244,7 +243,7 @@ class Vector {
/* Copy from inline buffer to newly allocated buffer. */
const int64_t capacity = size;
begin_ = static_cast<T *>(
- allocator_.allocate(sizeof(T) * static_cast<size_t>(capacity), alignof(T), AT));
+ allocator_.allocate(sizeof(T) * size_t(capacity), alignof(T), AT));
capacity_end_ = begin_ + capacity;
uninitialized_relocate_n(other.begin_, size, begin_);
end_ = begin_ + size;
@@ -693,7 +692,7 @@ class Vector {
*/
int64_t size() const
{
- const int64_t current_size = static_cast<int64_t>(end_ - begin_);
+ const int64_t current_size = int64_t(end_ - begin_);
BLI_assert(debug_size_ == current_size);
return current_size;
}
@@ -813,7 +812,7 @@ class Vector {
{
for (const T *current = begin_; current != end_; current++) {
if (*current == value) {
- return static_cast<int64_t>(current - begin_);
+ return int64_t(current - begin_);
}
}
return -1;
@@ -905,7 +904,7 @@ class Vector {
*/
int64_t capacity() const
{
- return static_cast<int64_t>(capacity_end_ - begin_);
+ return int64_t(capacity_end_ - begin_);
}
/**
@@ -975,7 +974,7 @@ class Vector {
const int64_t size = this->size();
T *new_array = static_cast<T *>(
- allocator_.allocate(static_cast<size_t>(new_capacity) * sizeof(T), alignof(T), AT));
+ allocator_.allocate(size_t(new_capacity) * sizeof(T), alignof(T), AT));
try {
uninitialized_relocate_n(begin_, size, new_array);
}
diff --git a/source/blender/blenlib/BLI_vector_set.hh b/source/blender/blenlib/BLI_vector_set.hh
index 1a42e776d3d..9e8cf5af59f 100644
--- a/source/blender/blenlib/BLI_vector_set.hh
+++ b/source/blender/blenlib/BLI_vector_set.hh
@@ -513,7 +513,7 @@ class VectorSet {
*/
int64_t size_in_bytes() const
{
- return static_cast<int64_t>(sizeof(Slot) * slots_.size() + sizeof(Key) * usable_slots_);
+ return int64_t(sizeof(Slot) * slots_.size() + sizeof(Key) * usable_slots_);
}
/**
@@ -557,7 +557,7 @@ class VectorSet {
max_load_factor_.compute_total_and_usable_slots(
SlotArray::inline_buffer_capacity(), min_usable_slots, &total_slots, &usable_slots);
BLI_assert(total_slots >= 1);
- const uint64_t new_slot_mask = static_cast<uint64_t>(total_slots) - 1;
+ const uint64_t new_slot_mask = uint64_t(total_slots) - 1;
/* Optimize the case when the set was empty beforehand. We can avoid some copies here. */
if (this->size() == 0) {
@@ -839,7 +839,7 @@ class VectorSet {
Key *allocate_keys_array(const int64_t size)
{
return static_cast<Key *>(
- slots_.allocator().allocate(sizeof(Key) * static_cast<size_t>(size), alignof(Key), AT));
+ slots_.allocator().allocate(sizeof(Key) * size_t(size), alignof(Key), AT));
}
void deallocate_keys_array(Key *keys)
diff --git a/source/blender/blenlib/BLI_virtual_array.hh b/source/blender/blenlib/BLI_virtual_array.hh
index 19ee2334bd9..217c8c00d66 100644
--- a/source/blender/blenlib/BLI_virtual_array.hh
+++ b/source/blender/blenlib/BLI_virtual_array.hh
@@ -324,7 +324,7 @@ class VArrayImpl_For_ArrayContainer : public VArrayImpl_For_Span<T> {
public:
VArrayImpl_For_ArrayContainer(Container container)
- : VArrayImpl_For_Span<T>((int64_t)container.size()), container_(std::move(container))
+ : VArrayImpl_For_Span<T>(int64_t(container.size())), container_(std::move(container))
{
this->data_ = const_cast<T *>(container_.data());
}
diff --git a/source/blender/blenlib/tests/BLI_linear_allocator_test.cc b/source/blender/blenlib/tests/BLI_linear_allocator_test.cc
index 8f707789954..778f048a8e7 100644
--- a/source/blender/blenlib/tests/BLI_linear_allocator_test.cc
+++ b/source/blender/blenlib/tests/BLI_linear_allocator_test.cc
@@ -9,7 +9,7 @@ namespace blender::tests {
static bool is_aligned(void *ptr, uint alignment)
{
- BLI_assert(is_power_of_2_i(static_cast<int>(alignment)));
+ BLI_assert(is_power_of_2_i(int(alignment)));
return (POINTER_AS_UINT(ptr) & (alignment - 1)) == 0;
}
diff --git a/source/blender/blenlib/tests/BLI_span_test.cc b/source/blender/blenlib/tests/BLI_span_test.cc
index 0d974786a1a..2dec84c4206 100644
--- a/source/blender/blenlib/tests/BLI_span_test.cc
+++ b/source/blender/blenlib/tests/BLI_span_test.cc
@@ -280,7 +280,7 @@ TEST(span, ContainsPtr)
EXPECT_TRUE(a_span.contains_ptr(&a[0] + 1));
EXPECT_TRUE(a_span.contains_ptr(&a[0] + 2));
EXPECT_FALSE(a_span.contains_ptr(&a[0] + 3));
- int *ptr_before = reinterpret_cast<int *>(reinterpret_cast<uintptr_t>(a.data()) - 1);
+ int *ptr_before = reinterpret_cast<int *>(uintptr_t(a.data()) - 1);
EXPECT_FALSE(a_span.contains_ptr(ptr_before));
EXPECT_FALSE(a_span.contains_ptr(&other));
}
diff --git a/source/blender/blenlib/tests/BLI_stack_cxx_test.cc b/source/blender/blenlib/tests/BLI_stack_cxx_test.cc
index 5c7f1106993..768d7199f68 100644
--- a/source/blender/blenlib/tests/BLI_stack_cxx_test.cc
+++ b/source/blender/blenlib/tests/BLI_stack_cxx_test.cc
@@ -118,19 +118,19 @@ TEST(stack, PushPopMany)
Stack<int> stack;
for (int i = 0; i < 1000; i++) {
stack.push(i);
- EXPECT_EQ(stack.size(), static_cast<uint>(i + 1));
+ EXPECT_EQ(stack.size(), uint(i + 1));
}
for (int i = 999; i > 50; i--) {
EXPECT_EQ(stack.pop(), i);
- EXPECT_EQ(stack.size(), static_cast<uint>(i));
+ EXPECT_EQ(stack.size(), uint(i));
}
for (int i = 51; i < 5000; i++) {
stack.push(i);
- EXPECT_EQ(stack.size(), static_cast<uint>(i + 1));
+ EXPECT_EQ(stack.size(), uint(i + 1));
}
for (int i = 4999; i >= 0; i--) {
EXPECT_EQ(stack.pop(), i);
- EXPECT_EQ(stack.size(), static_cast<uint>(i));
+ EXPECT_EQ(stack.size(), uint(i));
}
}
diff --git a/source/blender/blenlib/tests/BLI_string_ref_test.cc b/source/blender/blenlib/tests/BLI_string_ref_test.cc
index c3bb53f39d5..478b68a005e 100644
--- a/source/blender/blenlib/tests/BLI_string_ref_test.cc
+++ b/source/blender/blenlib/tests/BLI_string_ref_test.cc
@@ -357,7 +357,7 @@ TEST(string_ref, Constexpr)
constexpr StringRef sref("World");
BLI_STATIC_ASSERT(sref[2] == 'r', "");
BLI_STATIC_ASSERT(sref.size() == 5, "");
- std::array<int, static_cast<std::size_t>(sref.find_first_of('o'))> compiles = {1};
+ std::array<int, std::size_t(sref.find_first_of('o'))> compiles = {1};
EXPECT_EQ(compiles[0], 1);
}
} // namespace blender::tests