25 class CustomDelete :
public std::function<void(std::remove_extent_t<T> *)>
28 using T_decayed = std::remove_extent_t<T>;
31 using deleter_type = std::function<void(T_decayed *)>;
33 deleter_type
const &get_deleter()
const 37 deleter_type &get_deleter()
47 : deleter_type{[](T_decayed *ptr) {
48 if constexpr (std::is_void_v<T_decayed>)
51 std::cerr <<
"[Warning] Cannot standard-delete a void-type " 52 "pointer. Please specify a custom destructor. " 53 "Will let the memory leak." 58 std::default_delete<T>{}(ptr);
63 CustomDelete(deleter_type func) : deleter_type(std::move(func))
87 :
public std::unique_ptr<
89 auxiliary::CustomDelete<T>>
92 using BasePtr = std::unique_ptr<T, auxiliary::CustomDelete<T>>;
95 using T_decayed = std::remove_extent_t<T>;
115 template <
typename Del>
135 template <
typename U>
139 template <
typename T>
141 : BasePtr{stdPtr.release()}
144 template <
typename T>
145 template <
typename Del>
150 [deleter = std::move(ptr.get_deleter())](T_decayed *del_ptr) {
151 deleter.get_deleter()(del_ptr);
155 template <
typename T>
159 template <
typename T>
161 T_decayed *ptr, std::function<
void(T_decayed *)> deleter)
162 : BasePtr{ptr, std::move(deleter)}
165 template <
typename T>
166 template <
typename U>
169 using other_type = std::remove_extent_t<U>;
171 static_cast<other_type *
>(this->release()),
172 [deleter = std::move(this->get_deleter())](other_type *ptr) {
173 deleter.get_deleter()(
static_cast<T_decayed *
>(ptr));
Unique Pointer class that uses a dynamic destructor type.
Definition: UniquePtr.hpp:86
Public definitions of openPMD-api.
Custom deleter type based on std::function.
Definition: UniquePtr.hpp:25