X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2Fstlplus%2Fcontainers%2Fsmart_ptr.tpp;fp=src%2Fmoof%2Fstlplus%2Fsmart_ptr.tpp;h=ce72da22879a0af1d403fa64804c11591a400ac0;hp=cb1b8bbb825886754779bebcf2aabcc0980a793a;hb=6b0a0d0efafe34d48ab344fca3b479553bd4e62c;hpb=85783316365181491a3e3c0c63659972477cebba diff --git a/src/moof/stlplus/smart_ptr.tpp b/src/stlplus/containers/smart_ptr.tpp old mode 100755 new mode 100644 similarity index 91% rename from src/moof/stlplus/smart_ptr.tpp rename to src/stlplus/containers/smart_ptr.tpp index cb1b8bb..ce72da2 --- a/src/moof/stlplus/smart_ptr.tpp +++ b/src/stlplus/containers/smart_ptr.tpp @@ -33,7 +33,7 @@ namespace stlplus } public: - smart_ptr_holder(T* p = 0) : + smart_ptr_holder(T* p = 0) : m_count(1), m_data(p) { } @@ -139,6 +139,14 @@ namespace stlplus m_holder->increment(); } + // assignment operator - required, else the output of GCC suffers segmentation faults + template + smart_ptr_base& smart_ptr_base::operator=(const smart_ptr_base& r) + { + alias(r); + return *this; + } + // destructor decrements the reference count and delete only when the last reference is destroyed template smart_ptr_base::~smart_ptr_base(void) @@ -253,14 +261,7 @@ namespace stlplus template void smart_ptr_base::alias(const smart_ptr_base& r) { - // make it alias-copy safe - this means that I don't try to do the - // assignment if r is either the same object or an alias of it - // if (m_holder == r.m_holder) return; - // if (m_holder->decrement()) - // delete m_holder; - // m_holder = r.m_holder; - // m_holder->increment(); - make_alias(r.m_holder); + _make_alias(r.m_holder); } template @@ -319,15 +320,16 @@ namespace stlplus // used for example in persistence routines template - void* smart_ptr_base::handle(void) const + smart_ptr_holder* smart_ptr_base::_handle(void) const { return m_holder; } template - void smart_ptr_base::make_alias(void* handle) + void smart_ptr_base::_make_alias(smart_ptr_holder* r_holder) { - smart_ptr_holder* r_holder = (smart_ptr_holder*)handle; + // make it alias-copy safe - this means that I don't try to do the + // assignment if r is either the same object or an alias of it if (m_holder != r_holder) { if (m_holder->decrement())