diff options
Diffstat (limited to 'ue5/shared_ptr.hpp')
| -rw-r--r-- | ue5/shared_ptr.hpp | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/ue5/shared_ptr.hpp b/ue5/shared_ptr.hpp new file mode 100644 index 0000000..87e4b01 --- /dev/null +++ b/ue5/shared_ptr.hpp | |||
| @@ -0,0 +1,85 @@ | |||
| 1 | #ifndef SHARED_PTR_H | ||
| 2 | #define SHARED_PTR_H | ||
| 3 | |||
| 4 | /* TODO includes */ | ||
| 5 | |||
| 6 | #undef SOLVED_1 | ||
| 7 | //#define SOLVED_1 | ||
| 8 | |||
| 9 | namespace Ti { | ||
| 10 | |||
| 11 | /* TODO helpers */ | ||
| 12 | |||
| 13 | template <typename T> | ||
| 14 | class shared_ptr | ||
| 15 | { | ||
| 16 | private: | ||
| 17 | /* TODO data */ | ||
| 18 | |||
| 19 | public: | ||
| 20 | shared_ptr(); | ||
| 21 | T* get() const; | ||
| 22 | shared_ptr (const shared_ptr<T>& other); | ||
| 23 | |||
| 24 | template <typename O> | ||
| 25 | shared_ptr (const shared_ptr<O>& other); | ||
| 26 | |||
| 27 | template <typename O> | ||
| 28 | explicit shared_ptr (O* p); | ||
| 29 | shared_ptr& operator = (const shared_ptr<T>& other); | ||
| 30 | |||
| 31 | template <typename O> | ||
| 32 | shared_ptr& operator = (const shared_ptr<O>& other); | ||
| 33 | |||
| 34 | ~shared_ptr (); | ||
| 35 | T& operator * () const; | ||
| 36 | T* operator -> () const; | ||
| 37 | |||
| 38 | void swap (shared_ptr<T>& other); | ||
| 39 | |||
| 40 | inline void reset(); | ||
| 41 | |||
| 42 | private: | ||
| 43 | template <typename R, typename... Args> | ||
| 44 | friend shared_ptr<R> make_shared (Args...); | ||
| 45 | |||
| 46 | template<typename U1, typename U2> | ||
| 47 | friend bool operator == (const shared_ptr<U1>& a, const shared_ptr<U2>& b); | ||
| 48 | |||
| 49 | template<typename U1, typename U2> | ||
| 50 | friend bool operator == (const shared_ptr<U1>& a, const U2* b); | ||
| 51 | |||
| 52 | template<typename U1, typename U2> | ||
| 53 | friend bool operator == (const U1* a, const shared_ptr<U2>& b); | ||
| 54 | |||
| 55 | template<typename U1, typename U2> | ||
| 56 | friend bool operator != (const shared_ptr<U1>& a, const U2* b); | ||
| 57 | |||
| 58 | template<typename U1, typename U2> | ||
| 59 | friend bool operator != (const U1* a, const shared_ptr<U2>& b); | ||
| 60 | |||
| 61 | template<typename U1, typename U2> | ||
| 62 | friend bool operator != (const shared_ptr<U1>& a, const shared_ptr<U2>& b); | ||
| 63 | |||
| 64 | template <typename R, typename F> | ||
| 65 | friend shared_ptr<R> shared_dynamic_cast (const shared_ptr<F>& from); | ||
| 66 | }; | ||
| 67 | |||
| 68 | |||
| 69 | template <typename T /* TODO */ > | ||
| 70 | shared_ptr<T> make_shared (/* TODO */); | ||
| 71 | |||
| 72 | |||
| 73 | template <typename T, typename F> | ||
| 74 | shared_ptr<T> shared_dynamic_cast (const shared_ptr<F>& from); | ||
| 75 | |||
| 76 | } // end namespace ti | ||
| 77 | |||
| 78 | namespace std { | ||
| 79 | using namespace Ti; | ||
| 80 | template <typename T> | ||
| 81 | inline void swap (shared_ptr<T>& t1, shared_ptr<T>& t2); | ||
| 82 | /* TODO */ | ||
| 83 | } | ||
| 84 | |||
| 85 | #endif | ||
