#include <shared_ptr.h>
Inheritance diagram for cppdom_boost::shared_ptr:


Public Types | |
| typedef T | element_type |
Public Methods | |
| shared_ptr (T *p=0) | |
| shared_ptr (const shared_ptr &r) | |
| ~shared_ptr () | |
| shared_ptr & | operator= (const shared_ptr &r) |
| template<typename Y> | shared_ptr (const shared_ptr< Y > &r) |
| template<typename Y> | shared_ptr (std::auto_ptr< Y > &r) |
| template<typename Y> shared_ptr & | operator= (const shared_ptr< Y > &r) |
| template<typename Y> shared_ptr & | operator= (std::auto_ptr< Y > &r) |
| void | reset (T *p=0) |
| T & | operator * () const |
| T * | operator-> () const |
| T * | get () const |
| long | use_count () const |
| bool | unique () const |
| void | swap (shared_ptr< T > &other) |
Private Methods | |
| void | dispose () |
| void | share (T *rpx, long *rpn) |
Private Attributes | |
| T * | px |
| long * | pn |
Friends | |
| class | shared_ptr |
An enhanced relative of scoped_ptr with reference counted copy semantics. The object pointed to is deleted when the last shared_ptr pointing to it is destroyed or reset.
Definition at line 112 of file shared_ptr.h.
|
|||||
|
Definition at line 114 of file shared_ptr.h. |
|
||||||||||
|
Definition at line 116 of file shared_ptr.h.
|
|
||||||||||
|
Definition at line 121 of file shared_ptr.h.
|
|
|||||||||
|
Definition at line 123 of file shared_ptr.h.
00123 { dispose(); }
|
|
||||||||||||||
|
Definition at line 132 of file shared_ptr.h.
|
|
||||||||||||||
|
Definition at line 137 of file shared_ptr.h.
|
|
|||||||||
|
Definition at line 223 of file shared_ptr.h. Referenced by cppdom_boost::shared_ptr< class XMLEventHandler >::share(), and cppdom_boost::shared_ptr< class XMLEventHandler >::~shared_ptr().
|
|
|||||||||
|
Definition at line 196 of file shared_ptr.h. Referenced by cppdom_boost::operator!=(), and cppdom_boost::operator==().
00196 { return px; } // never throws
|
|
|||||||||
|
Definition at line 194 of file shared_ptr.h.
00194 { return *px; } // never throws
|
|
|||||||||
|
Definition at line 195 of file shared_ptr.h.
00195 { return px; } // never throws
|
|
||||||||||||||
|
Definition at line 149 of file shared_ptr.h.
00149 {
00150 // code choice driven by guarantee of "no effect if new throws"
00151 if (*pn == 1) { delete px; }
00152 else { // allocate new reference counter
00153 long * tmp = new long(1); // may throw
00154 --*pn; // only decrement once danger of new throwing is past
00155 pn = tmp;
00156 } // allocate new reference counter
00157 px = r.release(); // fix: moved here so doesn't leak if new throws
00158 return *this;
00159 }
|
|
||||||||||||||
|
Definition at line 143 of file shared_ptr.h.
00143 {
00144 share(r.px,r.pn);
00145 return *this;
00146 }
|
|
||||||||||
|
Definition at line 125 of file shared_ptr.h.
00125 {
00126 share(r.px,r.pn);
00127 return *this;
00128 }
|
|
||||||||||
|
Definition at line 179 of file shared_ptr.h.
00179 {
00180 if ( px == p ) return; // fix: self-assignment safe
00181 if (--*pn == 0) { delete px; }
00182 else { // allocate new reference counter
00183 try { pn = new long; } // fix: prevent leak if new throws
00184 catch (...) {
00185 ++*pn; // undo effect of --*pn above to meet effects guarantee
00186 delete p;
00187 throw;
00188 } // catch
00189 } // allocate new reference counter
00190 *pn = 1;
00191 px = p;
00192 } // reset
|
|
||||||||||||||||
|
Definition at line 225 of file shared_ptr.h. Referenced by cppdom_boost::shared_ptr< class XMLEventHandler >::operator=().
|
|
||||||||||
|
Definition at line 205 of file shared_ptr.h. Referenced by std::swap().
|
|
|||||||||
|
Definition at line 203 of file shared_ptr.h.
00203 { return *pn == 1; } // never throws
|
|
|||||||||
|
Definition at line 202 of file shared_ptr.h.
00202 { return *pn; } // never throws
|
|
|||||
|
Definition at line 220 of file shared_ptr.h. |
|
|||||
|
|||||
1.2.15