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>2021-07-05 13:14:50 +0300
committerJacques Lucke <jacques@blender.org>2021-07-05 14:02:16 +0300
commitded4dc77618c105aa6a5d25d480f9e23a1523b93 (patch)
treebae3e370daa10ab1e62cc204599090402ebad508 /source/blender/blenlib/BLI_memory_utils.hh
parentdc3f46d96b780260d982954578cac3bff74efd83 (diff)
BLI: add conversion constructor for destruct_ptr
This allows converting between different `destruct_ptr` types (which is just a `std::unique_ptr` with a custom deleter). The most common use case is to convert from a derived type to the type of the base class.
Diffstat (limited to 'source/blender/blenlib/BLI_memory_utils.hh')
-rw-r--r--source/blender/blenlib/BLI_memory_utils.hh6
1 files changed, 6 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_memory_utils.hh b/source/blender/blenlib/BLI_memory_utils.hh
index bdbbda9f0c7..14eca49d126 100644
--- a/source/blender/blenlib/BLI_memory_utils.hh
+++ b/source/blender/blenlib/BLI_memory_utils.hh
@@ -309,6 +309,12 @@ template<typename T> void uninitialized_fill_n(T *dst, int64_t n, const T &value
}
template<typename T> struct DestructValueAtAddress {
+ DestructValueAtAddress() = default;
+
+ template<typename U> DestructValueAtAddress(const U &)
+ {
+ }
+
void operator()(T *ptr)
{
ptr->~T();