diff options
author | Jacques Lucke <jacques@blender.org> | 2020-08-07 19:24:59 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2020-08-07 19:42:21 +0300 |
commit | c50e5fcc344d00b03eb4a3141b5b45944c3570fd (patch) | |
tree | f683ae1a1f38551d160a5be2ee86561d51faca26 /source/blender/blenlib/BLI_vector.hh | |
parent | 28b10224346a9a2e55267f98357991a841eeda5b (diff) |
Cleanup: use C++ style casts in various places
Diffstat (limited to 'source/blender/blenlib/BLI_vector.hh')
-rw-r--r-- | source/blender/blenlib/BLI_vector.hh | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/source/blender/blenlib/BLI_vector.hh b/source/blender/blenlib/BLI_vector.hh index 52e966267b5..48110ef2814 100644 --- a/source/blender/blenlib/BLI_vector.hh +++ b/source/blender/blenlib/BLI_vector.hh @@ -100,7 +100,8 @@ class Vector { */ #ifndef NDEBUG int64_t debug_size_; -# define UPDATE_VECTOR_SIZE(ptr) (ptr)->debug_size_ = (int64_t)((ptr)->end_ - (ptr)->begin_) +# define UPDATE_VECTOR_SIZE(ptr) \ + (ptr)->debug_size_ = static_cast<int64_t>((ptr)->end_ - (ptr)->begin_) #else # define UPDATE_VECTOR_SIZE(ptr) ((void)0) #endif @@ -243,7 +244,8 @@ class Vector { else { /* Copy from inline buffer to newly allocated buffer. */ const int64_t capacity = size; - begin_ = (T *)allocator_.allocate(sizeof(T) * (size_t)capacity, alignof(T), AT); + begin_ = static_cast<T *>( + allocator_.allocate(sizeof(T) * static_cast<size_t>(capacity), alignof(T), AT)); end_ = begin_ + size; capacity_end_ = begin_ + capacity; uninitialized_relocate_n(other.begin_, size, begin_); @@ -578,8 +580,9 @@ class Vector { */ int64_t size() const { - BLI_assert(debug_size_ == (int64_t)(end_ - begin_)); - return (int64_t)(end_ - begin_); + const int64_t current_size = static_cast<int64_t>(end_ - begin_); + BLI_assert(debug_size_ == current_size); + return current_size; } /** @@ -675,7 +678,7 @@ class Vector { { for (const T *current = begin_; current != end_; current++) { if (*current == value) { - return (int64_t)(current - begin_); + return static_cast<int64_t>(current - begin_); } } return -1; @@ -749,7 +752,7 @@ class Vector { */ int64_t capacity() const { - return (int64_t)(capacity_end_ - begin_); + return static_cast<int64_t>(capacity_end_ - begin_); } /** @@ -808,7 +811,8 @@ class Vector { const int64_t new_capacity = std::max(min_capacity, min_new_capacity); const int64_t size = this->size(); - T *new_array = (T *)allocator_.allocate((size_t)new_capacity * sizeof(T), alignof(T), AT); + T *new_array = static_cast<T *>( + allocator_.allocate(static_cast<size_t>(new_capacity) * sizeof(T), alignof(T), AT)); uninitialized_relocate_n(begin_, size, new_array); if (!this->is_inline()) { |