diff options
author | Jacques Lucke <jacques@blender.org> | 2021-07-05 13:14:50 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-07-05 14:02:16 +0300 |
commit | ded4dc77618c105aa6a5d25d480f9e23a1523b93 (patch) | |
tree | bae3e370daa10ab1e62cc204599090402ebad508 /source | |
parent | dc3f46d96b780260d982954578cac3bff74efd83 (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')
-rw-r--r-- | source/blender/blenlib/BLI_memory_utils.hh | 6 |
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(); |