You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
784 B
29 lines
784 B
#pragma once |
|
|
|
#include <cstddef> |
|
#include <memory> |
|
|
|
namespace devilution { |
|
|
|
// Apple Clang 12 has a buggy implementation that fails to compile `std::shared_ptr<T[]>(new T[size])`. |
|
#if (__cplusplus >= 201611L && (!defined(__clang_major__) || __clang_major__ >= 13)) && !defined(NXDK) && !defined(__ANDROID__) |
|
template <typename T> |
|
using ArraySharedPtr = std::shared_ptr<T[]>; |
|
|
|
template <typename T> |
|
ArraySharedPtr<T> MakeArraySharedPtr(std::size_t size) |
|
{ |
|
return ArraySharedPtr<T>(new T[size]); |
|
} |
|
#else |
|
template <typename T> |
|
using ArraySharedPtr = std::shared_ptr<T>; |
|
|
|
template <typename T> |
|
ArraySharedPtr<T> MakeArraySharedPtr(std::size_t size) |
|
{ |
|
return ArraySharedPtr<T> { new T[size], std::default_delete<T[]>() }; |
|
} |
|
#endif |
|
|
|
} // namespace devilution
|
|
|