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:
authorCampbell Barton <campbell@blender.org>2022-09-26 10:38:25 +0300
committerCampbell Barton <campbell@blender.org>2022-09-26 10:58:36 +0300
commit333e41eac6daf60c6aa9df0496a39c57d74b9c87 (patch)
tree5986e980fd64bc4ef1c3dda125a0f9dca4bab2c8 /source/blender/blenlib
parent0210c4df1793799a09a35e44be286dfca88769dc (diff)
Cleanup: replace C-style casts with functional casts for numeric types
Use function style casts in C++ headers & source.
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r--source/blender/blenlib/BLI_cpp_type.hh2
-rw-r--r--source/blender/blenlib/BLI_cpp_type_make.hh2
-rw-r--r--source/blender/blenlib/BLI_dot_export.hh2
-rw-r--r--source/blender/blenlib/BLI_hash_tables.hh6
-rw-r--r--source/blender/blenlib/BLI_linear_allocator.hh6
-rw-r--r--source/blender/blenlib/BLI_map.hh2
-rw-r--r--source/blender/blenlib/BLI_math_vector.hh2
-rw-r--r--source/blender/blenlib/BLI_memory_utils.hh2
-rw-r--r--source/blender/blenlib/BLI_set.hh2
-rw-r--r--source/blender/blenlib/BLI_string_ref.hh4
-rw-r--r--source/blender/blenlib/tests/BLI_exception_safety_test_utils.hh2
-rw-r--r--source/blender/blenlib/tests/BLI_vector_test.cc2
12 files changed, 17 insertions, 17 deletions
diff --git a/source/blender/blenlib/BLI_cpp_type.hh b/source/blender/blenlib/BLI_cpp_type.hh
index 8cf5ead1c7b..568ccbb5a64 100644
--- a/source/blender/blenlib/BLI_cpp_type.hh
+++ b/source/blender/blenlib/BLI_cpp_type.hh
@@ -297,7 +297,7 @@ class CPPType : NonCopyable, NonMovable {
*/
bool pointer_has_valid_alignment(const void *ptr) const
{
- return ((uintptr_t)ptr & alignment_mask_) == 0;
+ return (uintptr_t(ptr) & alignment_mask_) == 0;
}
bool pointer_can_point_to_instance(const void *ptr) const
diff --git a/source/blender/blenlib/BLI_cpp_type_make.hh b/source/blender/blenlib/BLI_cpp_type_make.hh
index 3acef4b0f09..1f494624821 100644
--- a/source/blender/blenlib/BLI_cpp_type_make.hh
+++ b/source/blender/blenlib/BLI_cpp_type_make.hh
@@ -271,7 +271,7 @@ CPPType::CPPType(CPPTypeParam<T, Flags> /* unused */, StringRef debug_name)
is_equal_ = is_equal_cb<T>;
}
- alignment_mask_ = (uintptr_t)alignment_ - (uintptr_t)1;
+ alignment_mask_ = uintptr_t(alignment_) - uintptr_t(1);
has_special_member_functions_ = (default_construct_ && copy_construct_ && copy_assign_ &&
move_construct_ && move_assign_ && destruct_);
}
diff --git a/source/blender/blenlib/BLI_dot_export.hh b/source/blender/blenlib/BLI_dot_export.hh
index b6decca0720..454f3c8412c 100644
--- a/source/blender/blenlib/BLI_dot_export.hh
+++ b/source/blender/blenlib/BLI_dot_export.hh
@@ -98,7 +98,7 @@ class Cluster {
std::string name() const
{
- return "cluster_" + std::to_string((uintptr_t)this);
+ return "cluster_" + std::to_string(uintptr_t(this));
}
void set_parent_cluster(Cluster *new_parent);
diff --git a/source/blender/blenlib/BLI_hash_tables.hh b/source/blender/blenlib/BLI_hash_tables.hh
index 85a8fd5d385..de65c58d4db 100644
--- a/source/blender/blenlib/BLI_hash_tables.hh
+++ b/source/blender/blenlib/BLI_hash_tables.hh
@@ -225,17 +225,17 @@ template<typename Pointer> struct PointerKeyInfo {
static bool is_empty(Pointer pointer)
{
- return (uintptr_t)pointer == UINTPTR_MAX;
+ return uintptr_t(pointer) == UINTPTR_MAX;
}
static bool is_removed(Pointer pointer)
{
- return (uintptr_t)pointer == UINTPTR_MAX - 1;
+ return uintptr_t(pointer) == UINTPTR_MAX - 1;
}
static bool is_not_empty_or_removed(Pointer pointer)
{
- return (uintptr_t)pointer < UINTPTR_MAX - 1;
+ return uintptr_t(pointer) < UINTPTR_MAX - 1;
}
};
diff --git a/source/blender/blenlib/BLI_linear_allocator.hh b/source/blender/blenlib/BLI_linear_allocator.hh
index 07211de3aed..a897845db45 100644
--- a/source/blender/blenlib/BLI_linear_allocator.hh
+++ b/source/blender/blenlib/BLI_linear_allocator.hh
@@ -207,8 +207,8 @@ template<typename Allocator = GuardedAllocator> class LinearAllocator : NonCopya
Span<char> buffer = unused_borrowed_buffers_[i];
if (buffer.size() >= min_allocation_size) {
unused_borrowed_buffers_.remove_and_reorder(i);
- current_begin_ = (uintptr_t)buffer.begin();
- current_end_ = (uintptr_t)buffer.end();
+ current_begin_ = uintptr_t(buffer.begin());
+ current_end_ = uintptr_t(buffer.end());
return;
}
}
@@ -226,7 +226,7 @@ template<typename Allocator = GuardedAllocator> class LinearAllocator : NonCopya
void *buffer = allocator_.allocate(size_in_bytes, min_alignment, __func__);
owned_buffers_.append(buffer);
- current_begin_ = (uintptr_t)buffer;
+ current_begin_ = uintptr_t(buffer);
current_end_ = current_begin_ + size_in_bytes;
}
diff --git a/source/blender/blenlib/BLI_map.hh b/source/blender/blenlib/BLI_map.hh
index d5bc53c4d6c..9fc5614c189 100644
--- a/source/blender/blenlib/BLI_map.hh
+++ b/source/blender/blenlib/BLI_map.hh
@@ -1314,7 +1314,7 @@ template<typename Key, typename Value> class StdUnorderedMapWrapper {
bool remove(const Key &key)
{
- return (bool)map_.erase(key);
+ return bool(map_.erase(key));
}
Value &lookup(const Key &key)
diff --git a/source/blender/blenlib/BLI_math_vector.hh b/source/blender/blenlib/BLI_math_vector.hh
index 3067232e8ea..e8303aa858b 100644
--- a/source/blender/blenlib/BLI_math_vector.hh
+++ b/source/blender/blenlib/BLI_math_vector.hh
@@ -366,7 +366,7 @@ template<typename T, BLI_ENABLE_IF((is_math_float_type<T>))>
inline vec_base<T, 3> cross_poly(Span<vec_base<T, 3>> poly)
{
/* Newell's Method. */
- int nv = static_cast<int>(poly.size());
+ int nv = int(poly.size());
if (nv < 3) {
return vec_base<T, 3>(0, 0, 0);
}
diff --git a/source/blender/blenlib/BLI_memory_utils.hh b/source/blender/blenlib/BLI_memory_utils.hh
index 0809f372b25..b6ffa6d8b4a 100644
--- a/source/blender/blenlib/BLI_memory_utils.hh
+++ b/source/blender/blenlib/BLI_memory_utils.hh
@@ -372,7 +372,7 @@ template<size_t Size, size_t Alignment> class AlignedBuffer {
*/
template<typename T, int64_t Size = 1> class TypedBuffer {
private:
- BLI_NO_UNIQUE_ADDRESS AlignedBuffer<sizeof(T) * (size_t)Size, alignof(T)> buffer_;
+ BLI_NO_UNIQUE_ADDRESS AlignedBuffer<sizeof(T) * size_t(Size), alignof(T)> buffer_;
public:
operator T *()
diff --git a/source/blender/blenlib/BLI_set.hh b/source/blender/blenlib/BLI_set.hh
index afe18529762..8fb618edeb6 100644
--- a/source/blender/blenlib/BLI_set.hh
+++ b/source/blender/blenlib/BLI_set.hh
@@ -917,7 +917,7 @@ template<typename Key> class StdUnorderedSetWrapper {
bool remove(const Key &key)
{
- return (bool)set_.erase(key);
+ return bool(set_.erase(key));
}
void remove_contained(const Key &key)
diff --git a/source/blender/blenlib/BLI_string_ref.hh b/source/blender/blenlib/BLI_string_ref.hh
index b202769e3c3..14dee54d730 100644
--- a/source/blender/blenlib/BLI_string_ref.hh
+++ b/source/blender/blenlib/BLI_string_ref.hh
@@ -585,7 +585,7 @@ inline std::ostream &operator<<(std::ostream &stream, StringRef ref)
inline std::ostream &operator<<(std::ostream &stream, StringRefNull ref)
{
- stream << std::string(ref.data(), (size_t)ref.size());
+ stream << std::string(ref.data(), size_t(ref.size()));
return stream;
}
@@ -611,7 +611,7 @@ constexpr bool operator==(StringRef a, StringRef b)
/* This also avoids passing null to the call below, which would results in an ASAN warning. */
return true;
}
- return STREQLEN(a.data(), b.data(), (size_t)a.size());
+ return STREQLEN(a.data(), b.data(), size_t(a.size()));
}
constexpr bool operator!=(StringRef a, StringRef b)
diff --git a/source/blender/blenlib/tests/BLI_exception_safety_test_utils.hh b/source/blender/blenlib/tests/BLI_exception_safety_test_utils.hh
index 63943e48f0e..367d8508a20 100644
--- a/source/blender/blenlib/tests/BLI_exception_safety_test_utils.hh
+++ b/source/blender/blenlib/tests/BLI_exception_safety_test_utils.hh
@@ -87,7 +87,7 @@ class ExceptionThrower {
uint64_t hash() const
{
- return static_cast<uint64_t>(value);
+ return uint64_t(value);
}
friend bool operator==(const ExceptionThrower &a, const ExceptionThrower &b)
diff --git a/source/blender/blenlib/tests/BLI_vector_test.cc b/source/blender/blenlib/tests/BLI_vector_test.cc
index 2dd220f562b..c603f5dff27 100644
--- a/source/blender/blenlib/tests/BLI_vector_test.cc
+++ b/source/blender/blenlib/tests/BLI_vector_test.cc
@@ -317,7 +317,7 @@ TEST(vector, BecomeLarge)
}
EXPECT_EQ(vec.size(), 100);
for (int i = 0; i < 100; i++) {
- EXPECT_EQ(vec[i], static_cast<int>(i * 5));
+ EXPECT_EQ(vec[i], int(i * 5));
}
}