1 #ifndef DOZERG_SHARED_PTR_H_20070828 2 #define DOZERG_SHARED_PTR_H_20070828 19 #include "impl/shared_ptr_impl.hh" 23 template<
class T,
class Alloc = std::allocator<T> >
27 typedef NS_IMPL::__RefImp<T, Alloc> __RefType;
29 typedef T element_type;
30 typedef T & reference;
32 typedef const T & const_reference;
33 typedef const T * const_pointer;
34 typedef typename __RefType::__ElemAlloc allocator_type;
36 typedef typename __RefType::__RefAlloc __RefAlloc;
37 typedef void (__Myt::*safe_bool_type)(pointer);
40 explicit CSharedPtr(pointer p = NULL):ref_(NULL){init(p);}
44 __RefType::changeRef(ref_, a.ref_);
46 ~
CSharedPtr()
throw(){__RefType::subRef(ref_);}
48 __Myt & operator =(
const __Myt & a)
throw(){
49 __RefType::changeRef(ref_, a.ref_);
52 __Myt & operator =(pointer a){
56 pointer
get()
const throw(){
return (
operator !() ? NULL : ref_->ptr_);}
57 pointer operator ->()
const throw(){
return get();}
58 reference operator *()
const throw(){
return *
get();}
59 bool operator !()
const throw(){
return !ref_;}
60 operator safe_bool_type()
const throw(){
return (
operator !() ? 0 : &__Myt::init);}
61 bool operator ==(
const __Myt & a)
const throw(){
return (ref_ == a.ref_);}
62 bool operator !=(
const __Myt & a)
const throw(){
return !operator ==(a);}
63 bool operator ==(const_pointer a)
const throw(){
64 return (
operator !() ? !a : a ==
operator ->());
66 bool operator !=(const_pointer a)
const throw(){
return !operator ==(a);}
67 void reset(pointer a = NULL){
69 __RefType::subRef(ref_);
73 void swap(__Myt & a)
throw(){std::swap(ref_, a.ref_);}
77 ref_ = tools::New1<__RefType>(p, __RefAlloc());
83 template<
class T,
class A>
89 template<
class T,
class A>
95 template<
class T,
class A>
Definition: shared_ptr.hh:24