Changeset 50213 in vbox for trunk/src/VBox/NetworkServices/NetLib/shared_ptr.h
- Timestamp:
- Jan 24, 2014 8:23:12 AM (11 years ago)
- svn:sync-xref-src-repo-rev:
- 91785
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/NetworkServices/NetLib/shared_ptr.h
r49339 r50213 3 3 4 4 #ifdef __cplusplus 5 template<typename T> 5 template<typename T> 6 6 class SharedPtr 7 7 { 8 struct imp 8 struct imp 9 9 { 10 10 imp(T *pTrg = NULL, int cnt = 1): ptr(pTrg),refcnt(cnt){} … … 15 15 }; 16 16 17 17 18 18 public: 19 19 SharedPtr(T *t = NULL):p(NULL) … … 21 21 p = new imp(t); 22 22 } 23 23 24 24 ~SharedPtr() 25 25 { … … 40 40 { 41 41 if (p == rhs.p) return *this; 42 42 43 43 p->refcnt--; 44 if (p->refcnt == 0) 44 if (p->refcnt == 0) 45 45 delete p; 46 46 … … 57 57 } 58 58 59 59 60 60 T *operator->() 61 61 { … … 63 63 } 64 64 65 65 66 66 const T*operator->() const 67 67 { … … 79 79 }; 80 80 #endif 81 81 82 #endif
Note:
See TracChangeset
for help on using the changeset viewer.