blob: 7e8a910459c052d51c0addedc997b5b65d4e8535 (
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
38
39
40
41
42
43
44
|
#pragma once
#include <stddef.h>
namespace common
{
template <class Target>
class SharedPtr
{
public:
SharedPtr() noexcept;
SharedPtr(nullptr_t) noexcept; // NOLINT(google-explicit-constructor)
explicit SharedPtr(Target *target) noexcept;
SharedPtr(const SharedPtr &shared_ptr) noexcept;
SharedPtr(SharedPtr &&shared_ptr) noexcept;
~SharedPtr() noexcept;
[[nodiscard]] unsigned int reference_cnt() const noexcept;
[[nodiscard]] bool is_disposable() const noexcept;
SharedPtr &operator=(const SharedPtr &rhs) noexcept;
SharedPtr &operator=(SharedPtr &&rhs) noexcept;
Target &operator*() const noexcept;
Target *operator->() const noexcept;
private:
Target *_target = nullptr;
unsigned int *_reference_cnt;
};
template <typename Target, typename... Args>
SharedPtr<Target> make_shared(Args &&...args) noexcept;
} // namespace common
#include "shared_ptr.tpp"
|