]> Dogcows Code - chaz/yoink/blobdiff - src/stlplus/containers/smart_ptr.tpp
testing new non-autotools build system
[chaz/yoink] / src / stlplus / containers / smart_ptr.tpp
old mode 100755 (executable)
new mode 100644 (file)
similarity index 91%
rename from src/moof/stlplus/smart_ptr.tpp
rename to src/stlplus/containers/smart_ptr.tpp
index cb1b8bb..ce72da2
@@ -33,7 +33,7 @@ namespace stlplus
       }\r
 \r
   public:\r
       }\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_count(1), m_data(p)\r
       {\r
       }\r
@@ -139,6 +139,14 @@ namespace stlplus
     m_holder->increment();\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
   // 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
@@ -253,14 +261,7 @@ namespace stlplus
   template <typename T, typename C>\r
   void smart_ptr_base<T,C>::alias(const smart_ptr_base<T,C>& r)\r
   {\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
   }\r
 \r
   template <typename T, typename C>\r
@@ -319,15 +320,16 @@ namespace stlplus
   // used for example in persistence routines\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
   {\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
   {\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
     if (m_holder != r_holder)\r
     {\r
       if (m_holder->decrement())\r
This page took 0.019715 seconds and 4 git commands to generate.