-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfullptr.hpp
More file actions
44 lines (28 loc) · 938 Bytes
/
fullptr.hpp
File metadata and controls
44 lines (28 loc) · 938 Bytes
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
#if !defined(INC_fullptr)
#define INC_fullptr
#include "perhaps.hpp"
template<class T> struct fullptr {
template <template <class> class V> static V<fullptr> make(T* p) {
if (p) { return fullptr{p}; } else { return {}; }
}
fullptr(fullptr const& x) : p(x.p) {}
fullptr(fullptr const&& x) : p(x.p) {}
~fullptr() {}
T* get() { return p; }
T const* get() const { return p; }
T* operator->() { return p;}
T const* operator->() const { return p;}
T& operator*() { return *p;}
T const& operator*() const { return *p;}
private:
fullptr(T*x) : p(x) {}
fullptr() = delete;
T* p;
};
template <template <class> class V, class T> inline V<fullptr<T>> make_fullptr(T* p) {
return fullptr<T>::template make<V>(p);
}
template <class T> inline perhaphs<fullptr<T>> make_fullptr(T* p) {
return fullptr<T>::template make<perhaps>(p);
}
#endif // !defined(INC_fullptr)