From e44045745d51622513f5733686f78db65d160263 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Thu, 11 Jun 2020 15:36:01 +0200 Subject: BLI: don't pass const pointers to placement new operator This resulted in compile errors. --- source/blender/blenlib/BLI_linear_allocator.hh | 2 +- source/blender/blenlib/BLI_map.hh | 2 +- source/blender/blenlib/BLI_map_slots.hh | 24 ++++++++++++------------ source/blender/blenlib/BLI_memory_utils.hh | 8 ++++---- source/blender/blenlib/BLI_optional.hh | 8 ++++---- source/blender/blenlib/BLI_set_slots.hh | 16 ++++++++-------- 6 files changed, 30 insertions(+), 30 deletions(-) (limited to 'source/blender/blenlib') diff --git a/source/blender/blenlib/BLI_linear_allocator.hh b/source/blender/blenlib/BLI_linear_allocator.hh index f968f9f15ce..2a0dc939cb9 100644 --- a/source/blender/blenlib/BLI_linear_allocator.hh +++ b/source/blender/blenlib/BLI_linear_allocator.hh @@ -171,7 +171,7 @@ template class LinearAllocator : NonCopya MutableSpan pointers = void_pointers.cast(); for (uint i : IndexRange(n)) { - new (pointers[i]) T(std::forward(args)...); + new ((void *)pointers[i]) T(std::forward(args)...); } return pointers; diff --git a/source/blender/blenlib/BLI_map.hh b/source/blender/blenlib/BLI_map.hh index 4fc9f98d835..f20f7b47647 100644 --- a/source/blender/blenlib/BLI_map.hh +++ b/source/blender/blenlib/BLI_map.hh @@ -1175,7 +1175,7 @@ class Map { bool add_overwrite__impl(ForwardKey &&key, ForwardValue &&value, uint32_t hash) { auto create_func = [&](Value *ptr) { - new (ptr) Value(std::forward(value)); + new ((void *)ptr) Value(std::forward(value)); return true; }; auto modify_func = [&](Value *ptr) { diff --git a/source/blender/blenlib/BLI_map_slots.hh b/source/blender/blenlib/BLI_map_slots.hh index 9ea2c4cad89..97d3baf0c83 100644 --- a/source/blender/blenlib/BLI_map_slots.hh +++ b/source/blender/blenlib/BLI_map_slots.hh @@ -84,8 +84,8 @@ template class SimpleMapSlot { { m_state = other.m_state; if (other.m_state == Occupied) { - new (this->key()) Key(*other.key()); - new (this->value()) Value(*other.value()); + new ((void *)this->key()) Key(*other.key()); + new ((void *)this->value()) Value(*other.value()); } } @@ -98,8 +98,8 @@ template class SimpleMapSlot { { m_state = other.m_state; if (other.m_state == Occupied) { - new (this->key()) Key(std::move(*other.key())); - new (this->value()) Value(std::move(*other.value())); + new ((void *)this->key()) Key(std::move(*other.key())); + new ((void *)this->value()) Value(std::move(*other.value())); } } @@ -170,8 +170,8 @@ template class SimpleMapSlot { BLI_assert(!this->is_occupied()); BLI_assert(other.is_occupied()); m_state = Occupied; - new (this->key()) Key(std::move(*other.key())); - new (this->value()) Value(std::move(*other.value())); + new ((void *)this->key()) Key(std::move(*other.key())); + new ((void *)this->value()) Value(std::move(*other.value())); other.key()->~Key(); other.value()->~Value(); } @@ -198,7 +198,7 @@ template class SimpleMapSlot { { BLI_assert(!this->is_occupied()); this->occupy_without_value(std::forward(key), hash); - new (this->value()) Value(std::forward(value)); + new ((void *)this->value()) Value(std::forward(value)); } /** @@ -209,7 +209,7 @@ template class SimpleMapSlot { { BLI_assert(!this->is_occupied()); m_state = Occupied; - new (this->key()) Key(std::forward(key)); + new ((void *)this->key()) Key(std::forward(key)); } /** @@ -251,14 +251,14 @@ template class IntrusiveMapSlot IntrusiveMapSlot(const IntrusiveMapSlot &other) : m_key(other.m_key) { if (KeyInfo::is_not_empty_or_removed(m_key)) { - new (this->value()) Value(*other.value()); + new ((void *)this->value()) Value(*other.value()); } } IntrusiveMapSlot(IntrusiveMapSlot &&other) noexcept : m_key(other.m_key) { if (KeyInfo::is_not_empty_or_removed(m_key)) { - new (this->value()) Value(std::move(*other.value())); + new ((void *)this->value()) Value(std::move(*other.value())); } } @@ -303,7 +303,7 @@ template class IntrusiveMapSlot BLI_assert(!this->is_occupied()); BLI_assert(other.is_occupied()); m_key = std::move(other.m_key); - new (this->value()) Value(std::move(*other.value())); + new ((void *)this->value()) Value(std::move(*other.value())); other.m_key.~Key(); other.value()->~Value(); } @@ -321,7 +321,7 @@ template class IntrusiveMapSlot BLI_assert(!this->is_occupied()); BLI_assert(KeyInfo::is_not_empty_or_removed(key)); this->occupy_without_value(std::forward(key), hash); - new (this->value()) Value(std::forward(value)); + new ((void *)this->value()) Value(std::forward(value)); } template void occupy_without_value(ForwardKey &&key, uint32_t UNUSED(hash)) diff --git a/source/blender/blenlib/BLI_memory_utils.hh b/source/blender/blenlib/BLI_memory_utils.hh index c317376fe8e..55dca98fb07 100644 --- a/source/blender/blenlib/BLI_memory_utils.hh +++ b/source/blender/blenlib/BLI_memory_utils.hh @@ -46,7 +46,7 @@ template void default_construct_n(T *ptr, uint n) } for (uint i = 0; i < n; i++) { - new (ptr + i) T; + new ((void *)(ptr + i)) T; } } @@ -102,7 +102,7 @@ template void initialized_copy_n(const T *src, uint n, T *dst) template void uninitialized_copy_n(const T *src, uint n, T *dst) { for (uint i = 0; i < n; i++) { - new (dst + i) T(src[i]); + new ((void *)(dst + i)) T(src[i]); } } @@ -136,7 +136,7 @@ template void initialized_move_n(T *src, uint n, T *dst) template void uninitialized_move_n(T *src, uint n, T *dst) { for (uint i = 0; i < n; i++) { - new (dst + i) T(std::move(src[i])); + new ((void *)(dst + i)) T(std::move(src[i])); } } @@ -200,7 +200,7 @@ template void initialized_fill_n(T *dst, uint n, const T &value) template void uninitialized_fill_n(T *dst, uint n, const T &value) { for (uint i = 0; i < n; i++) { - new (dst + i) T(value); + new ((void *)(dst + i)) T(value); } } diff --git a/source/blender/blenlib/BLI_optional.hh b/source/blender/blenlib/BLI_optional.hh index b5f98d6fa97..2e6b66d0eac 100644 --- a/source/blender/blenlib/BLI_optional.hh +++ b/source/blender/blenlib/BLI_optional.hh @@ -121,7 +121,7 @@ template class Optional { this->value() = value; } else { - new (this->value_ptr()) T(value); + new ((void *)this->value_ptr()) T(value); m_set = true; } } @@ -132,7 +132,7 @@ template class Optional { this->value() = std::move(value); } else { - new (this->value_ptr()) T(std::move(value)); + new ((void *)this->value_ptr()) T(std::move(value)); m_set = true; } } @@ -140,14 +140,14 @@ template class Optional { void set_new(const T &value) { BLI_assert(!m_set); - new (this->value_ptr()) T(value); + new ((void *)this->value_ptr()) T(value); m_set = true; } void set_new(T &&value) { BLI_assert(!m_set); - new (this->value_ptr()) T(std::move(value)); + new ((void *)this->value_ptr()) T(std::move(value)); m_set = true; } diff --git a/source/blender/blenlib/BLI_set_slots.hh b/source/blender/blenlib/BLI_set_slots.hh index 15f56f2450e..581e70ce628 100644 --- a/source/blender/blenlib/BLI_set_slots.hh +++ b/source/blender/blenlib/BLI_set_slots.hh @@ -80,7 +80,7 @@ template class SimpleSetSlot { { m_state = other.m_state; if (other.m_state == Occupied) { - new (this->key()) Key(*other.key()); + new ((void *)this->key()) Key(*other.key()); } } @@ -93,7 +93,7 @@ template class SimpleSetSlot { { m_state = other.m_state; if (other.m_state == Occupied) { - new (this->key()) Key(std::move(*other.key())); + new ((void *)this->key()) Key(std::move(*other.key())); } } @@ -148,7 +148,7 @@ template class SimpleSetSlot { BLI_assert(!this->is_occupied()); BLI_assert(other.is_occupied()); m_state = Occupied; - new (this->key()) Key(std::move(*other.key())); + new ((void *)this->key()) Key(std::move(*other.key())); other.key()->~Key(); } @@ -173,7 +173,7 @@ template class SimpleSetSlot { { BLI_assert(!this->is_occupied()); m_state = Occupied; - new (this->key()) Key(std::forward(key)); + new ((void *)this->key()) Key(std::forward(key)); } /** @@ -221,7 +221,7 @@ template class HashedSetSlot { m_state = other.m_state; if (other.m_state == Occupied) { m_hash = other.m_hash; - new (this->key()) Key(*other.key()); + new ((void *)this->key()) Key(*other.key()); } } @@ -230,7 +230,7 @@ template class HashedSetSlot { m_state = other.m_state; if (other.m_state == Occupied) { m_hash = other.m_hash; - new (this->key()) Key(std::move(*other.key())); + new ((void *)this->key()) Key(std::move(*other.key())); } } @@ -266,7 +266,7 @@ template class HashedSetSlot { BLI_assert(other.is_occupied()); m_state = Occupied; m_hash = hash; - new (this->key()) Key(std::move(*other.key())); + new ((void *)this->key()) Key(std::move(*other.key())); other.key()->~Key(); } @@ -287,7 +287,7 @@ template class HashedSetSlot { BLI_assert(!this->is_occupied()); m_state = Occupied; m_hash = hash; - new (this->key()) Key(std::forward(key)); + new ((void *)this->key()) Key(std::forward(key)); } void remove() -- cgit v1.2.3