Changeset 5823 for code/branches/core5/src/libraries/core/SmartPtr.h
- Timestamp:
- Sep 28, 2009, 5:16:36 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core5/src/libraries/core/SmartPtr.h
r5807 r5823 35 35 36 36 #include <cassert> 37 #include <ostream> 37 38 38 #include "OrxonoxClass.h" 39 #include "WeakPtr.h" 39 40 40 41 namespace orxonox … … 71 72 } 72 73 74 template <class O> 75 inline SmartPtr(const WeakPtr<O>& other) : pointer_(other.get()), base_(other.getBase()) 76 { 77 if (this->base_) 78 this->base_->incrementReferenceCount(); 79 } 80 73 81 inline ~SmartPtr() 74 82 { … … 102 110 } 103 111 112 template <class O> 113 inline const SmartPtr& operator=(const WeakPtr<O>& other) 114 { 115 SmartPtr(other).swap(*this); 116 return *this; 117 } 118 104 119 inline T* get() const 105 120 { 106 121 return this->pointer_; 122 } 123 124 inline OrxonoxClass* getBase() const 125 { 126 return this->base_; 107 127 } 108 128 … … 153 173 }; 154 174 155 template <class A, class B>156 inline bool operator==(const SmartPtr<A>& a, const SmartPtr<B>& b)157 {158 return (a.get() == b.get());159 }160 161 template <class A, class B>162 inline bool operator!=(const SmartPtr<A>& a, const SmartPtr<B>& b)163 {164 return (a.get() != b.get());165 }166 167 template <class T>168 inline bool operator<(const SmartPtr<T>& a, const SmartPtr<T>& b)169 {170 return std::less<T*>()(a.get(), b.get());171 }172 173 175 template <class T> 174 176 void swap(SmartPtr<T>& a, SmartPtr<T>& b) … … 194 196 return dynamic_cast<T*>(p.get()); 195 197 } 196 197 template <class T>198 std::ostream& operator<<(std::ostream& os, const SmartPtr<T>& p)199 {200 os << p.get();201 return os;202 }203 198 } 204 199
Note: See TracChangeset
for help on using the changeset viewer.