blob: 94c02d000ff24697ddd9e1058d76c6ae5abaa229 (
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
34
35
36
37
|
#pragma once
namespace common
{
template <class Target>
class UniquePtr
{
public:
explicit UniquePtr() = default;
explicit UniquePtr(Target *target);
// Move constructor
UniquePtr(UniquePtr &&unique_ptr) noexcept;
// Move assignment operator
UniquePtr &operator=(UniquePtr &&unique_ptr) noexcept;
// Disable the copy constructor
UniquePtr(const UniquePtr &unique_ptr) = delete;
// Disable the copy assignment operator
UniquePtr &operator=(const UniquePtr &unique_ptr) = delete;
~UniquePtr();
Target operator*() const;
Target *operator->() const;
private:
Target *_target = nullptr;
};
template <typename Target, typename... Args>
UniquePtr<Target> make_unique(Args... args);
} // namespace common
#include "unique_ptr.tpp"
|