2022-12-06 15:41:22 +00:00
|
|
|
#pragma once
|
2023-01-13 19:00:20 +00:00
|
|
|
#include <luna/Heap.h>
|
|
|
|
#include <luna/PlacementNew.h>
|
2022-12-06 15:41:22 +00:00
|
|
|
#include <luna/Result.h>
|
|
|
|
|
2022-12-07 10:01:45 +00:00
|
|
|
template <typename T, class... Args> [[nodiscard]] Result<T*> make(Args... args)
|
2022-12-06 15:41:22 +00:00
|
|
|
{
|
2023-01-13 19:00:20 +00:00
|
|
|
T* const result = (T*)TRY(malloc_impl(sizeof(T)));
|
|
|
|
new (result) T(args...);
|
2022-12-06 15:41:22 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T> void destroy(T* item)
|
|
|
|
{
|
|
|
|
delete item;
|
|
|
|
}
|