fix(smart_holder): Use std::default_delete. (#4924)

Ensures `std::default_delete<T>` is used to look up the deleter for a type instead of `delete` directly.
This commit is contained in:
Ivor Wanders 2023-11-06 18:56:21 -05:00 committed by GitHub
parent edfaaed87e
commit e02fe001cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -103,7 +103,7 @@ struct guarded_delete {
template <typename T, typename std::enable_if<std::is_destructible<T>::value, int>::type = 0> template <typename T, typename std::enable_if<std::is_destructible<T>::value, int>::type = 0>
inline void builtin_delete_if_destructible(void *raw_ptr) { inline void builtin_delete_if_destructible(void *raw_ptr) {
delete static_cast<T *>(raw_ptr); std::default_delete<T>{}(static_cast<T *>(raw_ptr));
} }
template <typename T, typename std::enable_if<!std::is_destructible<T>::value, int>::type = 0> template <typename T, typename std::enable_if<!std::is_destructible<T>::value, int>::type = 0>