summaryrefslogtreecommitdiffstats
path: root/ue5/shared_ptr.hpp
blob: 87e4b019cd80ed1e3aaca64e4ced631377719495 (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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#ifndef SHARED_PTR_H
#define SHARED_PTR_H

/* TODO includes */

#undef SOLVED_1
//#define SOLVED_1

namespace Ti {

/* TODO helpers */

template <typename T>
class shared_ptr
{
private:
	/* TODO data */

public:
	shared_ptr();
	T* get() const;
	shared_ptr (const shared_ptr<T>& other);

	template <typename O>
	shared_ptr (const shared_ptr<O>& other);

	template <typename O>
	explicit shared_ptr (O* p);
	shared_ptr& operator = (const shared_ptr<T>& other);

	template <typename O>
	shared_ptr& operator = (const shared_ptr<O>& other);

	~shared_ptr ();
	T& operator * () const;
	T* operator -> () const;

	void swap (shared_ptr<T>& other);

	inline void reset();

private:
	template <typename R, typename... Args>
	friend shared_ptr<R> make_shared (Args...);

	template<typename U1, typename U2>
	friend bool operator == (const shared_ptr<U1>& a, const shared_ptr<U2>& b);

	template<typename U1, typename U2>
	friend bool operator == (const shared_ptr<U1>& a, const U2* b);

	template<typename U1, typename U2>
	friend bool operator == (const U1* a, const shared_ptr<U2>& b);

	template<typename U1, typename U2>
	friend bool operator != (const shared_ptr<U1>& a, const U2* b);

	template<typename U1, typename U2>
	friend bool operator != (const U1* a, const shared_ptr<U2>& b);

	template<typename U1, typename U2>
	friend bool operator != (const shared_ptr<U1>& a, const shared_ptr<U2>& b);

	template <typename R, typename F>
	friend shared_ptr<R> shared_dynamic_cast (const shared_ptr<F>& from);
};


template <typename T /* TODO */ >
shared_ptr<T> make_shared (/* TODO */);


template <typename T, typename F>
shared_ptr<T> shared_dynamic_cast (const shared_ptr<F>& from);

} // end namespace ti

namespace std {
	using namespace Ti;
	template <typename T>
	inline void swap (shared_ptr<T>& t1, shared_ptr<T>& t2);
	/* TODO */
}

#endif