}\r
\r
public:\r
- smart_ptr_holder(T* p = 0) : \r
+ smart_ptr_holder(T* p = 0) :\r
m_count(1), m_data(p)\r
{\r
}\r
m_holder->increment();\r
}\r
\r
+ // assignment operator - required, else the output of GCC suffers segmentation faults\r
+ template <typename T, typename C>\r
+ smart_ptr_base<T,C>& smart_ptr_base<T,C>::operator=(const smart_ptr_base<T,C>& r) \r
+ {\r
+ alias(r);\r
+ return *this;\r
+ }\r
+\r
// destructor decrements the reference count and delete only when the last reference is destroyed\r
template <typename T, typename C>\r
smart_ptr_base<T,C>::~smart_ptr_base(void)\r
template <typename T, typename C>\r
void smart_ptr_base<T,C>::alias(const smart_ptr_base<T,C>& r)\r
{\r
- // make it alias-copy safe - this means that I don't try to do the\r
- // assignment if r is either the same object or an alias of it\r
- // if (m_holder == r.m_holder) return;\r
- // if (m_holder->decrement())\r
- // delete m_holder;\r
- // m_holder = r.m_holder;\r
- // m_holder->increment();\r
- make_alias(r.m_holder);\r
+ _make_alias(r.m_holder);\r
}\r
\r
template <typename T, typename C>\r
// used for example in persistence routines\r
\r
template <typename T, typename C>\r
- void* smart_ptr_base<T,C>::handle(void) const\r
+ smart_ptr_holder<T>* smart_ptr_base<T,C>::_handle(void) const\r
{\r
return m_holder;\r
}\r
\r
template <typename T, typename C>\r
- void smart_ptr_base<T,C>::make_alias(void* handle)\r
+ void smart_ptr_base<T,C>::_make_alias(smart_ptr_holder<T>* r_holder)\r
{\r
- smart_ptr_holder<T>* r_holder = (smart_ptr_holder<T>*)handle;\r
+ // make it alias-copy safe - this means that I don't try to do the\r
+ // assignment if r is either the same object or an alias of it\r
if (m_holder != r_holder)\r
{\r
if (m_holder->decrement())\r