feat make_unique support T* ptr

This commit is contained in:
tqcq 2024-07-10 18:55:11 +08:00 committed by tqcq
parent 9e85ebb784
commit 9bd627ea6c

View File

@ -17,6 +17,12 @@ make_unique(Args &&...args) {
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
}
template <typename T, typename... Args>
inline enable_if_t<!std::is_array<T>::value, std::unique_ptr<T>>
make_unique(T *ptr) {
return std::unique_ptr<T>(ptr);
}
// dynamic array
template <typename T>
inline enable_if_t<std::is_array<T>::value && std::extent<T>::value == 0,