-
Notifications
You must be signed in to change notification settings - Fork 0
/
pointer.hpp
34 lines (23 loc) · 865 Bytes
/
pointer.hpp
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
#pragma once
namespace nall {
template<typename T>
struct pointer {
explicit operator bool() const { return value; }
pointer() = default;
pointer(T* source) { value = source; }
pointer(const pointer& source) { value = source.value; }
auto& operator=(T* source) { value = source; return *this; }
auto& operator=(const pointer& source) { value = source.value; return *this; }
auto operator()() -> T* { return value; }
auto operator()() const -> const T* { return value; }
auto operator->() -> T* { return value; }
auto operator->() const -> const T* { return value; }
auto operator*() -> T& { return *value; }
auto operator*() const -> const T& { return *value; }
auto reset() -> void { value = nullptr; }
auto data() -> T* { return value; }
auto data() const -> const T* { return value; }
private:
T* value = nullptr;
};
}