Skip to content

Commit 1fe8d93

Browse files
committed
Add deleter struct for std::unique_ptr destruction policy
1 parent 264608b commit 1fe8d93

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

include/libpmr/new.h

+10
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include <cstddef>
1010
#include <algorithm>
11+
#include <type_traits>
1112

1213
#include "libimp/aligned.h"
1314
#include "libimp/uninitialized.h"
@@ -167,4 +168,13 @@ void $delete(T *p) noexcept {
167168
#endif
168169
}
169170

171+
/// \brief The destruction policy used by std::unique_ptr.
172+
/// \see https://en.cppreference.com/w/cpp/memory/default_delete
173+
struct deleter {
174+
template <typename T>
175+
void operator()(T *p) const noexcept {
176+
$delete(p);
177+
}
178+
};
179+
170180
LIBPMR_NAMESPACE_END_

0 commit comments

Comments
 (0)