From 1fe8d9361276ceb8c22e151ee2f107ac414bad8e Mon Sep 17 00:00:00 2001 From: mutouyun Date: Mon, 16 Sep 2024 19:22:41 +0800 Subject: [PATCH] Add deleter struct for std::unique_ptr destruction policy --- include/libpmr/new.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/libpmr/new.h b/include/libpmr/new.h index d3a70e1..ab1dfb0 100644 --- a/include/libpmr/new.h +++ b/include/libpmr/new.h @@ -8,6 +8,7 @@ #include #include +#include #include "libimp/aligned.h" #include "libimp/uninitialized.h" @@ -167,4 +168,13 @@ void $delete(T *p) noexcept { #endif } +/// \brief The destruction policy used by std::unique_ptr. +/// \see https://en.cppreference.com/w/cpp/memory/default_delete +struct deleter { + template + void operator()(T *p) const noexcept { + $delete(p); + } +}; + LIBPMR_NAMESPACE_END_