diff options
Diffstat (limited to 'src/core/memory.h')
| -rw-r--r-- | src/core/memory.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/core/memory.h b/src/core/memory.h new file mode 100644 index 0000000..3240c71 --- /dev/null +++ b/src/core/memory.h @@ -0,0 +1,24 @@ +#pragma once + +#include <memory> + +namespace Donut +{ + template<typename T> + using Ref = std::shared_ptr<T>; + + template<typename T> + using Scope = std::unique_ptr<T>; + + template<typename T, typename ... Args> + constexpr auto create_scope(Args&& ... args) -> Scope<T> + { + return std::make_unique<T>(std::forward<Args>(args)...); + } + + template<typename T, typename ... Args> + constexpr auto create_ref(Args&& ... args) -> Ref<T> + { + return std::make_shared<T>(std::forward<Args>(args)...); + } +}; |
