16 #define LUG_NEW_ALIGN(T, alignment, ...) ::lug::System::Memory::new_one<T>(alignment, __FILE__, __LINE__, __VA_ARGS__) 17 #define LUG_NEW_ARRAY_ALIGN(T, alignment, ...) LUG_NEW_ARRAY_ALIGN_SIZE(typename std::remove_all_extents<T>::type, alignment, std::extent<T>::value, __VA_ARGS__) 18 #define LUG_NEW_ARRAY_ALIGN_SIZE(T, alignment, size, ...) ::lug::System::Memory::new_array<typename std::remove_all_extents<T>::type>(alignment, size, __FILE__, __LINE__, __VA_ARGS__) 20 #define LUG_NEW(T, ...) LUG_NEW_ALIGN(T, alignof(T), __VA_ARGS__) 21 #define LUG_DELETE(object, arena) ::lug::System::Memory::delete_one(object, arena) 23 #define LUG_NEW_ARRAY(T, ...) LUG_NEW_ARRAY_ALIGN(T, alignof(typename std::remove_all_extents<T>::type), __VA_ARGS__) 24 #define LUG_NEW_ARRAY_SIZE(T, size, ...) LUG_NEW_ARRAY_ALIGN_SIZE(T, alignof(typename std::remove_all_extents<T>::type), size, __VA_ARGS__) 25 #define LUG_DELETE_ARRAY(object, arena) ::lug::System::Memory::delete_array(object, arena) 32 template <
typename T,
class Arena,
class ...Args>
33 T*
new_one(
size_t alignment,
const char* file,
size_t line, Arena& arena, Args&&... args);
35 template <
typename T,
class Arena>
38 template <
typename T,
class Arena,
class ...Args,
typename std::enable_if<!std::is_pod<T>::value,
int>::type = 0>
39 T*
new_array(
size_t alignment,
size_t nb,
const char* file,
size_t line, Arena& arena, Args&&... args);
41 template <typename T, class Arena, typename std::enable_if<!std::is_pod<T>::value,
int>::type = 0>
44 template <typename T, class Arena, typename std::enable_if<std::is_pod<T>::value,
int>::type = 0>
45 T*
new_array(
size_t alignment,
size_t nb,
const char* file,
size_t line, Arena& arena);
47 template <
typename T,
class Arena,
class ...Args,
typename std::enable_if<std::is_pod<T>::value,
int>::type = 0>
48 T*
new_array(
size_t alignment,
size_t nb,
const char* file,
size_t line, Arena& arena, Args&&... args) =
delete;
50 template <typename T, class Arena, typename std::enable_if<std::is_pod<T>::value,
int>::type = 0>
60 struct make_unique_deleter {
61 using Deleter = std::function<void (T*)>;
65 struct make_unique_deleter<T[]> {
66 using Deleter = std::function<void (T*)>;
69 template <
typename T,
size_t Count>
70 struct make_unique_deleter<T[Count]> {
71 using Deleter = std::function<void (T*)>;
79 template<typename T, typename Deleter = typename priv::make_unique_deleter<T>::Deleter>
88 struct make_unique_if {
93 struct make_unique_if<T[]> {
97 template <
typename T,
size_t Count>
98 struct make_unique_if<T[Count]> {
108 template <
typename T,
class Arena,
typename ...Args>
109 typename priv::make_unique_if<T>::SingleObject
make_unique(Arena& arena, Args&&... args);
111 template <
typename T,
class Arena,
typename ...Args>
112 typename priv::make_unique_if<T>::SingleObject
make_unique_align(Arena& arena,
size_t alignment, Args&&... args);
115 template <
typename T,
class Arena,
typename ...Args,
typename std::enable_if<!std::is_pod<T>::value,
int>::type = 0>
116 typename priv::make_unique_if<T>::UnknownBound
make_unique(Arena& arena,
size_t size, Args&&... args);
118 template <
typename T,
class Arena,
typename ...Args,
typename std::enable_if<!std::is_pod<T>::value,
int>::type = 0>
119 typename priv::make_unique_if<T>::UnknownBound
make_unique_align(Arena& arena,
size_t alignment,
size_t size, Args&&... args);
121 template <typename T, class Arena, typename std::enable_if<std::is_pod<T>::value,
int>::type = 0>
122 typename priv::make_unique_if<T>::UnknownBound
make_unique(Arena& arena,
size_t size);
124 template <typename T, class Arena, typename std::enable_if<std::is_pod<T>::value,
int>::type = 0>
125 typename priv::make_unique_if<T>::UnknownBound
make_unique_align(Arena& arena,
size_t alignment,
size_t size);
127 template <
typename T,
class Arena,
typename ...Args,
typename std::enable_if<std::is_pod<T>::value,
int>::type = 0>
128 typename priv::make_unique_if<T>::UnknownBound
make_unique(Arena& arena,
size_t size, Args&&... args) =
delete;
130 template <
typename T,
class Arena,
typename ...Args,
typename std::enable_if<std::is_pod<T>::value,
int>::type = 0>
131 typename priv::make_unique_if<T>::UnknownBound
make_unique_align(Arena& arena,
size_t alignment,
size_t size, Args&&... args) =
delete;
134 template <
typename T,
class Arena,
typename ...Args,
typename std::enable_if<!std::is_pod<T>::value,
int>::type = 0>
135 typename priv::make_unique_if<T>::KnownBound
make_unique(Arena& arena, Args&&... args);
137 template <
typename T,
class Arena,
typename ...Args,
typename std::enable_if<!std::is_pod<T>::value,
int>::type = 0>
138 typename priv::make_unique_if<T>::KnownBound
make_unique_align(Arena& arena,
size_t alignment, Args&&... args);
140 template <typename T, class Arena, typename std::enable_if<std::is_pod<T>::value,
int>::type = 0>
141 typename priv::make_unique_if<T>::KnownBound
make_unique(Arena& arena);
143 template <typename T, class Arena, typename std::enable_if<std::is_pod<T>::value,
int>::type = 0>
144 typename priv::make_unique_if<T>::KnownBound
make_unique_align(Arena& arena,
size_t alignment);
146 template <
typename T,
class Arena,
typename ...Args,
typename std::enable_if<std::is_pod<T>::value,
int>::type = 0>
147 typename priv::make_unique_if<T>::KnownBound
make_unique(Arena& arena, Args&&... args) =
delete;
149 template <
typename T,
class Arena,
typename ...Args,
typename std::enable_if<std::is_pod<T>::value,
int>::type = 0>
150 typename priv::make_unique_if<T>::KnownBound
make_unique_align(Arena& arena,
size_t alignment, Args&&... args) =
delete;
void delete_array(T *ptr, Arena &arena)
priv::make_unique_if< T >::SingleObject make_unique_align(Arena &arena, size_t alignment, Args &&... args)
T * new_one(size_t alignment, const char *file, size_t line, Arena &arena, Args &&... args)
void delete_one(T *object, Arena &arena)
std::unique_ptr< T, Deleter > unique_ptr
priv::make_unique_if< T >::SingleObject make_unique(Arena &arena, Args &&... args)
T * new_array(size_t alignment, size_t nb, const char *file, size_t line, Arena &arena, Args &&... args)