aboutsummaryrefslogtreecommitdiff
path: root/src/Core/Memory.h
blob: 3240c71227abfdb9e82b9f39c0c8b17c24f05864 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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)...);
	}
};