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.
This commit is contained in:
Jacques Lucke 2021-07-05 12:14:50 +02:00
parent dc3f46d96b
commit ded4dc7761
1 changed files with 6 additions and 0 deletions

View File

@ -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();