Commit 2f05671b authored by Shai Szulanski's avatar Shai Szulanski Committed by Facebook GitHub Bot

Use std::default_delete by default in folly::erased_unique_ptr

Summary: To match the behavior of non-erased unique_ptr

Reviewed By: yfeldblum

Differential Revision: D30160280

fbshipit-source-id: 7fc624fa973c5cc1effc1746b5bee6c835d28150
parent 379e39cc
...@@ -434,12 +434,20 @@ std::shared_ptr<remove_cvref_t<T>> copy_to_shared_ptr(T&& t) { ...@@ -434,12 +434,20 @@ std::shared_ptr<remove_cvref_t<T>> copy_to_shared_ptr(T&& t) {
// A type-erased smart-ptr with unique ownership to a heap-allocated object. // A type-erased smart-ptr with unique ownership to a heap-allocated object.
using erased_unique_ptr = std::unique_ptr<void, void (*)(void*)>; using erased_unique_ptr = std::unique_ptr<void, void (*)(void*)>;
namespace detail {
// for erased_unique_ptr with types that specialize default_delete
template <typename T>
void erased_unique_ptr_delete(void* ptr) {
std::default_delete<T>()(static_cast<T*>(ptr));
}
} // namespace detail
// to_erased_unique_ptr // to_erased_unique_ptr
// //
// Converts an owning pointer to an object to an erased_unique_ptr. // Converts an owning pointer to an object to an erased_unique_ptr.
template <typename T> template <typename T>
erased_unique_ptr to_erased_unique_ptr(T* const ptr) noexcept { erased_unique_ptr to_erased_unique_ptr(T* const ptr) noexcept {
return {ptr, detail::thunk::ruin<T>}; return {ptr, detail::erased_unique_ptr_delete<T>};
} }
// to_erased_unique_ptr // to_erased_unique_ptr
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment