33 #define NO_MEMBER_TEMPLATES 38 typedef X element_type;
41 : itsCounter(0) {
if (p) itsCounter =
new counter(p);}
45 {acquire(r.itsCounter);}
50 acquire(r.itsCounter);
55 #ifndef NO_MEMBER_TEMPLATES 58 {acquire(r.itsCounter);}
63 acquire(r.itsCounter);
67 #endif // NO_MEMBER_TEMPLATES 69 X& operator*()
const throw() {
return *itsCounter->ptr;}
70 X* operator->()
const throw() {
return itsCounter->ptr;}
71 X*
get()
const throw() {
return itsCounter ? itsCounter->ptr : 0;}
72 bool unique()
const throw()
73 {
return (itsCounter ? itsCounter->count == 1 :
true);}
75 operator X*()
const throw() {
return get(); }
80 counter(X* p = 0,
unsigned c = 1) : ptr(p), count(c) {}
85 void acquire(counter* c)
throw()
94 if (--itsCounter->count == 0) {
95 delete itsCounter->ptr;
103 #endif // COUNTED_PTR_H Definition: counted_ptr.h:35