summaryrefslogtreecommitdiff
path: root/src/utils/memory.hpp
blob: e870b0b5554c083d5f99c223d720f2dd711c2707 (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
25
26
27
28
29
30
31
32
33
#pragma once

#include <stddef.h>

template <typename memType>
memType *malloc_s(unsigned int size);

template <class Target>
class UniquePtr
{
public:
	explicit UniquePtr();
	explicit UniquePtr(Target *target);
	UniquePtr(const UniquePtr &unique_ptr);
	UniquePtr(UniquePtr &&unique_ptr) noexcept;

	UniquePtr &operator=(const UniquePtr &unique_ptr);

	UniquePtr &operator=(UniquePtr &&unique_ptr) noexcept;

	~UniquePtr();

	Target operator*() const;
	Target *operator->() const;

private:
	Target *_target = nullptr;
};

template <typename Target, typename... Args>
UniquePtr<Target> make_unique(Args... args);

#include "memory.tpp"