$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
From: phil_at_[hidden]
Date: 2008-08-04 05:07:04
Author: pbouchard
Date: 2008-08-04 05:07:02 EDT (Mon, 04 Aug 2008)
New Revision: 47963
URL: http://svn.boost.org/trac/boost/changeset/47963
Log:
Adjusted a lot of definitions (alloc::value_type / pointer, node_base::hook, ...)
Text files modified: 
   sandbox/shifted_ptr/bits/list.tcc                                |    31 ++++---                                 
   sandbox/shifted_ptr/bits/stl_list.h                              |    41 +++++----                               
   sandbox/shifted_ptr/boost/detail/sh_owned_base_nt.hpp            |   158 +++++++++++++++++---------------------- 
   sandbox/shifted_ptr/boost/detail/shifted_ptr_base.hpp            |    32 -------                                 
   sandbox/shifted_ptr/boost/shifted_allocator.hpp                  |    20 ++--                                    
   sandbox/shifted_ptr/boost/shifted_ptr.hpp                        |    97 ++++++------------------                
   sandbox/shifted_ptr/libs/smart_ptr/example/shifted_ptr_test2.cpp |    14 ++-                                     
   7 files changed, 156 insertions(+), 237 deletions(-)
Modified: sandbox/shifted_ptr/bits/list.tcc
==============================================================================
--- sandbox/shifted_ptr/bits/list.tcc	(original)
+++ sandbox/shifted_ptr/bits/list.tcc	2008-08-04 05:07:02 EDT (Mon, 04 Aug 2008)
@@ -76,12 +76,17 @@
 {
   template<typename _Alloc>
     void
-    _List_node_base<_Alloc>::hook(_List_node_base * const __position)
+    _List_node_base<_Alloc>::hook(value_type * const __position)
     {
-        this->_M_next = __position;
-        this->_M_prev = __position->_M_prev;
-        __position->_M_prev->_M_next = this;
-        __position->_M_prev = this;
+        static_cast<_List_node_base &>(*__position)._M_next = this->_M_next->_M_prev;
+        static_cast<_List_node_base &>(*__position)._M_prev = this->_M_prev;
+        this->_M_prev->_M_next = __position;
+        this->_M_prev = __position;
+
+//        this->_M_next = __position;
+//        this->_M_prev = __position->_M_prev;
+//        __position->_M_prev->_M_next = this;
+//        __position->_M_prev = this;
     }
 
   template<typename _Alloc>
@@ -99,17 +104,17 @@
     _List_base<_Tp,_Alloc>::
     _M_clear()
     {
-      typedef _List_node<_Tp,_Alloc>  _Node;
+/*      typedef _List_node<_Tp,_Alloc>  _Node;
       typedef _List_node_base<_Alloc>  _Node_base;
-      _Node* __cur = static_cast<_Node*>(static_cast<_Node_base*>(&*this->_M_impl._M_node->_M_next));
-      while (__cur != &*this->_M_impl._M_node)
+      typename _Node_base::pointer* __cur = & this->_M_impl._M_node->_M_next;
+      while (__cur != & this->_M_impl._M_node)
       {
-        _Node* __tmp = __cur;
-        __cur = static_cast<_Node*>(static_cast<_Node_base*>(&*__cur->_M_next));
-        std::_Destroy(&__tmp->_M_data);
-        _M_put_node(__tmp);
+        typename _Node_base::pointer* __tmp = __cur;
+        __cur = & (*__cur)->_M_next;
+        _M_impl._Node_Alloc_type::destroy(*(typename _Node::pointer*) __tmp);
+        _M_put_node(*(typename _Node::pointer*) __tmp);
       }
-    }
+*/    }
 
   template<typename _Tp, typename _Alloc>
     typename list<_Tp,_Alloc>::iterator
Modified: sandbox/shifted_ptr/bits/stl_list.h
==============================================================================
--- sandbox/shifted_ptr/bits/stl_list.h	(original)
+++ sandbox/shifted_ptr/bits/stl_list.h	2008-08-04 05:07:02 EDT (Mon, 04 Aug 2008)
@@ -87,6 +87,7 @@
     {
       typedef typename _Alloc::template rebind<_List_node_base<_Alloc> >::other _Node_Alloc_type;
 
+      typedef typename _Node_Alloc_type::value_type                value_type;
       typedef typename _Node_Alloc_type::pointer                   pointer;
       typedef typename _Node_Alloc_type::const_pointer             const_pointer;
       typedef typename _Node_Alloc_type::reference                 reference;
@@ -99,14 +100,14 @@
       swap(_List_node_base& __x, _List_node_base& __y);
 
       void
-      transfer(_List_node_base * const __first,
-	       _List_node_base * const __last);
+      transfer(value_type * const __first,
+	       value_type * const __last);
 
       void
       reverse();
 
       void
-      hook(_List_node_base * const __position);
+      hook(value_type * const __position);
 
       void
       unhook();
@@ -118,6 +119,7 @@
     {
       typedef typename _Alloc::template rebind<_List_node<_Tp, _Alloc> >::other _Node_Alloc_type;
 
+      typedef typename _Node_Alloc_type::value_type                value_type;
       typedef typename _Node_Alloc_type::pointer                   pointer;
       typedef typename _Node_Alloc_type::const_pointer             const_pointer;
       typedef typename _Node_Alloc_type::reference                 reference;
@@ -320,26 +322,28 @@
       // get_allocator, where we use conversions between
       // allocator_type and _Node_Alloc_type. The conversion is
       // required by table 32 in [20.1.5].
-      typedef typename _Alloc::template rebind<_List_node<_Tp, _Alloc> >::other
-
-      _Node_Alloc_type;
+      typedef typename _Alloc::template rebind<_List_node<_Tp, _Alloc> >::other _Node_Alloc_type;
 
       struct _List_impl
         : public _Node_Alloc_type {
         typename _List_node_base<_Alloc>::pointer _M_node;
         _List_impl (const _Node_Alloc_type& __a, _List_base& __b)
-          : _Node_Alloc_type(__a), _M_node(new (__b._M_get_node()) _List_node_base<_Alloc>())
-        { }
+          : _Node_Alloc_type(__a)
+        { 
+            typename _Node_Alloc_type::value_type * __p = __b._M_get_node();
+            _Node_Alloc_type::construct(__p, _List_node<_Tp, _Alloc>());
+            _M_node = __p;
+        }
       };
 
       _List_impl _M_impl;
 
-      _List_node<_Tp, _Alloc> *
+      typename _Node_Alloc_type::value_type *
       _M_get_node()
       { return _M_impl._Node_Alloc_type::allocate(1); }
 
       void
-      _M_put_node(_List_node<_Tp, _Alloc> * __p)
+      _M_put_node(typename _Node_Alloc_type::pointer & __p)
       { _M_impl._Node_Alloc_type::deallocate(__p, 1); }
 
   public:
@@ -457,17 +461,17 @@
        *  Allocates space for a new node and constructs a copy of @a x in it.
        *  @endif
        */
-      _Node*
+      typename _Base::_Node_Alloc_type::value_type*
       _M_create_node(const value_type& __x)
       {
-        _Node* __p = this->_M_get_node();
+        typename _Base::_Node_Alloc_type::value_type* __p = this->_M_get_node();
         try
           {
             _M_impl._Base::_Node_Alloc_type::construct(__p, _Node(__x));
           }
         catch(...)
           {
-            _M_put_node(__p);
+            //_M_put_node(__p);
             __throw_exception_again;
           }
         return __p;
@@ -479,17 +483,17 @@
        *  instance of @c value_type in it.
        *  @endif
        */
-      _Node*
+      typename _Base::_Node_Alloc_type::value_type*
       _M_create_node()
       {
-        _Node* __p = this->_M_get_node();
+        typename _Base::_Node_Alloc_type::value_type* __p = this->_M_get_node();
         try
           {
             _M_impl._Base::_Node_Alloc_type::construct(__p, _Node());
           }
         catch(...)
           {
-            _M_put_node(__p);
+            //_M_put_node(__p);
             __throw_exception_again;
           }
         return __p;
@@ -1188,8 +1192,9 @@
       void
       _M_insert(iterator __position, const value_type& __x)
       {
-        _Node* __tmp = _M_create_node(__x);
-        __tmp->hook(__position._M_node);
+        __position._M_node->hook(reinterpret_cast<typename _List_node_base<_Alloc>::value_type*>(_M_create_node(__x)));
+        //typename _Base::_Node_Alloc_type::value_type* __tmp = _M_create_node(__x);
+        //static_cast<_Node &>(*__tmp).hook(__position._M_node);
       }
 
       // Erases element at position given.
Modified: sandbox/shifted_ptr/boost/detail/sh_owned_base_nt.hpp
==============================================================================
--- sandbox/shifted_ptr/boost/detail/sh_owned_base_nt.hpp	(original)
+++ sandbox/shifted_ptr/boost/detail/sh_owned_base_nt.hpp	2008-08-04 05:07:02 EDT (Mon, 04 Aug 2008)
@@ -25,7 +25,6 @@
 
 #include <stack>
 #include <limits>
-#include <utility>
 
 // Bypassing linkage by default
 #define BOOST_SH_DISABLE_THREADS
@@ -34,6 +33,7 @@
 #include <boost/thread/tss.hpp>
 #include <boost/pool/pool.hpp>
 #include <boost/pool/pool_alloc.hpp>
+#include <boost/numeric/interval.hpp>
 #include <boost/type_traits/is_array.hpp>
 #include <boost/type_traits/remove_extent.hpp>
 #include <boost/type_traits/has_trivial_destructor.hpp>
@@ -64,116 +64,92 @@
 
 
 /**
-    Allocator wrapper tracking allocations.
+    Syntax helper.
 */
 
-struct pool : boost::pool<>
-{
-    typedef std::list< std::pair<char *, char *>, fast_pool_allocator< std::pair<char *, char *> > > lpp;
+typedef std::list< numeric::interval<int>, fast_pool_allocator< numeric::interval<int> > > pool_lii;
+
 
+/**
+    Allocator wrapper tracking allocations.
+*/
 
+struct pool : boost::pool<>,
+#ifndef BOOST_SH_DISABLE_THREADS
+    thread_specific_ptr<pool_lii>
+#else
+    std::auto_ptr<pool_lii>
+#endif
+{
     pool() : boost::pool<>(1)
     {
-        alloc_.reset(new lpp());
-        constr_.reset(new lpp());
+        reset(new pool_lii());
     }
-
-    /**
-        @brief
-        This function returns the most recent allocation block that contains p.
-
-        @note
-        Every block allocated after p is discarded.
-    */
-
+    
     owned_base * top(void * p)
     {
-        char * const q = static_cast<char *>(p);
-
-        lpp::reverse_iterator i;
-        for (i = alloc_.get()->rbegin(); i != alloc_.get()->rend(); i ++)
-            if (i->first <= q && q <= i->second)
+        pool_lii::reverse_iterator i;
+        
+        for (i = get()->rbegin(); i != get()->rend(); i ++)
+            if (in((int)(p), * i))
                 break;
 
-        alloc_.get()->erase(i.base(), alloc_.get()->end());
-
-        return (owned_base *)(i->first);
-    }
-
-    lpp & construct()
-    {
-        return * alloc_.get();
+        get()->erase(i.base(), get()->end());
+        
+        return (owned_base *)(i->lower());
     }
-
+    
     void * allocate(std::size_t s)
     {
-        char * p = static_cast<char *>(ordered_malloc(s));
-
-        alloc_.get()->push_back(std::make_pair(p, p + s));
-
+        void * p = ordered_malloc(s);
+        
+        get()->push_back(numeric::interval<int>((int) p, int((char *)(p) + s)));
+        
         return p;
     }
 
     void deallocate(void * p, std::size_t s)
     {
-        char * const q = static_cast<char *>(p);
-
-        lpp::reverse_iterator i;
-        for (i = alloc_.get()->rbegin(); i != alloc_.get()->rend(); i ++)
-            if (i->first <= q && q <= i->second)
+        pool_lii::reverse_iterator i;
+        
+        for (i = get()->rbegin(); i != get()->rend(); i ++)
+            if (in((int)(p), * i))
                 break;
-
-        alloc_.get()->erase(i.base(), alloc_.get()->end());
+        
+        get()->erase(i.base(), get()->end());
         free(p, s);
     }
-
-private:
-#ifndef BOOST_SH_DISABLE_THREADS
-    thread_specific_ptr<lpp> alloc_, constr_;
-#else
-    std::auto_ptr<lpp> alloc_, constr_;
-#endif
 };
 
 
-template <typename T>
-    class shifted_allocator;
-
 /**
         Root class of all pointees.
 */
 
 class owned_base : public sp_counted_base
 {
-    template <typename U> friend class shifted_allocator;
-
-    bool init_;
-    intrusive_stack ptrs_;
-    intrusive_list inits_;
+	intrusive_stack ptrs_;
+	intrusive_list inits_;
 
 protected:
-    owned_base() : init_(false)
-    {
-        inits_.push_back(& init_tag_);
-    }
+    virtual void dispose() 				                    {} // dummy
+    virtual void * get_deleter( std::type_info const & ti ) { return 0; } // dummy
 
 public:
     intrusive_list::node set_tag_;
     intrusive_list::node init_tag_;
 
-    intrusive_stack * ptrs() 					{ return & ptrs_; }
-    intrusive_list * inits()					{ return & inits_; }
+    owned_base()
+    {
+        inits_.push_back(& init_tag_); 
+    }
+
+    intrusive_stack * ptrs() 						{ return & ptrs_; }
+    intrusive_list * inits()						{ return & inits_; }
     intrusive_list::node * set_tag() 				{ return & set_tag_; }
     intrusive_list::node * init_tag() 				{ return & init_tag_; }
 
-    bool init()                                                 { return init_; }
-    void init(bool b)                                           { init_ = b; }
-
     static pool pool_;
-
-private:
-    virtual void dispose() 				            {} // dummy
-    virtual void * get_deleter( std::type_info const & ti ) {} // dummy
 };
 
 
@@ -185,8 +161,8 @@
 #define PARAMETER_DECL(z, n, text) BOOST_PP_COMMA_IF(n) t ## n
 
 #define CONSTRUCT_OWNED(z, n, text)																			    \
-    template <BOOST_PP_REPEAT(n, TEMPLATE_DECL, 0)>										                        \
-        text(BOOST_PP_REPEAT(n, ARGUMENT_DECL, 0)) : e_(BOOST_PP_REPEAT(n, PARAMETER_DECL, 0)) {}
+	template <BOOST_PP_REPEAT(n, TEMPLATE_DECL, 0)>										                        \
+		text(BOOST_PP_REPEAT(n, ARGUMENT_DECL, 0)) : elem_(BOOST_PP_REPEAT(n, PARAMETER_DECL, 0)) {}																										
 
 /**
         Object wrapper.
@@ -197,22 +173,27 @@
     {
         typedef T data_type;
 
-        data_type e_; // need alignas<long>
-
+        T elem_; // need alignas<long>
+        
     public:
         class roofof;
         friend class roofof;
 
-        shifted() : e_() {}
+		shifted() : elem_() 
+        {
+        }
 
         BOOST_PP_REPEAT_FROM_TO(1, 10, CONSTRUCT_OWNED, shifted)
 
-        data_type * element() 				{ return & e_; }
 
-        virtual ~shifted()					{ dispose(); }
-        virtual void dispose() 				{ /*dispose(element(), is_array<data_type>());*/ }
-
-        virtual void * get_deleter( std::type_info const & ti ) { return 0; } // dummy
+        data_type * element() 				{ return & elem_; }
+        operator data_type & ()             { return * element(); }
+        operator data_type const & () const { return * element(); }
+
+        virtual ~shifted()					
+        { 
+            dispose(); 
+        }
 
     public:
         class roofof
@@ -220,18 +201,16 @@
             shifted<data_type> * p_;
 
         public:
-            roofof(data_type * p) : p_(sh::roofof((data_type shifted<data_type>::*)(& shifted<data_type>::e_), p)) {}
-
+            roofof(data_type * p) : p_(sh::roofof((data_type shifted<data_type>::*)(& shifted<data_type>::elem_), p)) {}
+            
             operator shifted<data_type> * () const { return p_; }
         };
-
+        
         void * operator new (size_t s)
         {
-//std::cout << std::hex << __FUNCTION__ << ": " << s << std::endl;
-
             return pool_.allocate(s);
         }
-
+        
         void operator delete (void * p)
         {
             pool_.deallocate(p, sizeof(shifted));
@@ -244,7 +223,7 @@
     {
         typedef void data_type;
 
-        long p_;
+        long elem_;
 
         shifted();
 
@@ -252,7 +231,7 @@
         class roofof;
         friend class roofof;
 
-        data_type * element() 				{ return & p_; }
+        data_type * element() 				{ return & elem_; }
 
         virtual ~shifted()					{}
         virtual void dispose() 				{}
@@ -265,12 +244,13 @@
             shifted<data_type> * p_;
 
         public:
-            roofof(data_type * p) : p_(sh::roofof((long shifted<data_type>::*)(& shifted<data_type>::p_), static_cast<long *>(p))) {}
-
+            roofof(data_type * p) : p_(sh::roofof((long shifted<data_type>::*)(& shifted<data_type>::elem_), static_cast<long *>(p))) {}
+            
             operator shifted<data_type> * () const { return p_; }
         };
     };
 
+
 } // namespace sh
 
 } // namespace detail
Modified: sandbox/shifted_ptr/boost/detail/shifted_ptr_base.hpp
==============================================================================
--- sandbox/shifted_ptr/boost/detail/shifted_ptr_base.hpp	(original)
+++ sandbox/shifted_ptr/boost/detail/shifted_ptr_base.hpp	2008-08-04 05:07:02 EDT (Mon, 04 Aug 2008)
@@ -112,16 +112,6 @@
                         }
                         return po_;
                 }
-        
-        bool operator == (shifted_ptr_base<element_type> const & p) const
-        {
-            return po_ == p.po_;
-        }
-
-        bool operator != (shifted_ptr_base<element_type> const & p) const
-        {
-            return po_ != p.po_;
-        }
 
                 void reset(element_type * p = 0)
                 {
@@ -225,16 +215,6 @@
                         }
                         return po_;
                 }
-        
-        bool operator == (shifted_ptr_base<element_type> const & p) const
-        {
-            return po_ == p.po_;
-        }
-
-        bool operator != (shifted_ptr_base<element_type> const & p) const
-        {
-            return po_ != p.po_;
-        }
 
                 void reset(element_type * p = 0)
                 {
@@ -255,7 +235,7 @@
 
 
         protected:
-		owned_base * header() const
+		detail::sh::owned_base * header() const
                 {
                         return (shifted<element_type> *) (typename shifted<element_type>::roofof) static_cast<element_type *>(rootof<is_polymorphic<element_type>::value>::get(po_));
                 }
@@ -327,16 +307,6 @@
                         }
                         return po_;
                 }
-        
-        bool operator == (shifted_ptr_base<element_type> const & p) const
-        {
-            return po_ == p.po_;
-        }
-
-        bool operator != (shifted_ptr_base<element_type> const & p) const
-        {
-            return po_ != p.po_;
-        }
 
                 void reset(element_type * p = 0)
                 {
Modified: sandbox/shifted_ptr/boost/shifted_allocator.hpp
==============================================================================
--- sandbox/shifted_ptr/boost/shifted_allocator.hpp	(original)
+++ sandbox/shifted_ptr/boost/shifted_allocator.hpp	2008-08-04 05:07:02 EDT (Mon, 04 Aug 2008)
@@ -44,13 +44,13 @@
     class shifted_allocator
     {
     public:
+        typedef shifted<T>              value_type;
         typedef size_t                  size_type;
         typedef ptrdiff_t               difference_type;
         typedef shifted_ptr<T>          pointer;
         typedef const shifted_ptr<T>    const_pointer;
-        typedef T &                     reference;
-        typedef const T &               const_reference;
-        typedef T                       value_type;
+        typedef value_type &            reference;
+        typedef const value_type &      const_reference;
 
         template <typename U>
             struct rebind
@@ -69,12 +69,12 @@
 
         value_type * allocate(size_type s, const void * = 0)
         {
-            shifted<T> * p = (shifted<T> *) shifted<T>::operator new(sizeof(shifted<T>));
+            value_type * p = (value_type *) value_type::operator new(sizeof(value_type));
 
-            return static_cast<shifted<T> *>(::new (p) owned_base)->element();
+            return p;
         }
 
-        void deallocate(value_type * p, size_type)
+        void deallocate(pointer & p, size_type)
         {
         }
 
@@ -83,13 +83,15 @@
             return size_t(-1) / sizeof(T);
         }
 
-        void construct(value_type * p, const value_type & x)
+        void construct(value_type * p, const T & x)
         {
-            ::new (p) T(x);
+            ::new (p) owned_base;
+            ::new (p->element()) T(x);
         }
 
-        void destroy(value_type * p)
+        void destroy(pointer & p)
         {
+            p.reset();
         }
     };
 
Modified: sandbox/shifted_ptr/boost/shifted_ptr.hpp
==============================================================================
--- sandbox/shifted_ptr/boost/shifted_ptr.hpp	(original)
+++ sandbox/shifted_ptr/boost/shifted_ptr.hpp	2008-08-04 05:07:02 EDT (Mon, 04 Aug 2008)
@@ -21,7 +21,6 @@
 #ifndef BOOST_DETAIL_SH_RTCMM_H_INCLUDED
 #define BOOST_DETAIL_SH_RTCMM_H_INCLUDED
 
-#include <iterator>
 
 #if defined(_MSC_VER)
 #pragma warning( push )
@@ -86,11 +85,11 @@
                 i->add_ref_copy();
                 delete &* i;
             }
-
+                
             for (intrusive_list::iterator<set, & set::tag_> i = p->includes_.begin(), j; j = i, ++ j, i != p->includes_.end(); i = j)
                 if (&* i != this && &* i != p)
                     delete &* i;
-
+                    
             if (p != this)
                 delete p;
 
@@ -121,14 +120,12 @@
     {
         return & redir()->elements_;
     }
-
+    
     void * operator new (size_t s)
     {
-        char * p = reinterpret_cast<char *>(pool_.allocate(s));
-
-        return p;
+        return pool_.allocate(s);
     }
-
+    
     void * operator new (size_t s, set * p)
     {
         return p;
@@ -140,6 +137,7 @@
     }
 };
 
+
 fast_pool_allocator<set> set::pool_;
 
 
@@ -151,8 +149,9 @@
     class shifted_ptr : public shifted_ptr_base<T>
     {
         //template <typename, template <typename> class> friend class shifted_ptr;
-        typedef shifted_ptr_base<T> base;
 
+        typedef shifted_ptr_base<T> base;
+        
         using base::share;
 
 
@@ -198,8 +197,7 @@
                 else
                     owned_base::pool_.top(this)->ptrs()->push(& pn_);
 
-                if (init())
-                    ps_->redir(p.ps_);
+                ps_->redir(p.ps_);
             }
 
             shifted_ptr(shifted_ptr<T> const & p) : base(p)
@@ -209,16 +207,17 @@
                 else
                     owned_base::pool_.top(this)->ptrs()->push(& pn_);
 
-                if (init())
-                    ps_->redir(p.ps_);
+                ps_->redir(p.ps_);
             }
 
         template <typename V>
             shifted_ptr & operator = (shifted<V> * p)
             {
-                if (init())
+                if (ps_ && ! owned_base::pool_.is_from(ps_))
                 {
-                    release();
+                    if (! owned_base::pool_.is_from(this))
+                        release();
+
                     init(p);
                 }
                 base::operator = (p);
@@ -229,15 +228,14 @@
         template <typename V>
             shifted_ptr & operator = (shifted_ptr<V> const & p)
             {
-                if (p.po_ != base::po_)
-                {
-                    if (init() && ps_->redir() != p.ps_->redir())
+                if (ps_ && ! owned_base::pool_.is_from(ps_))
+                    if (ps_->redir() != p.ps_->redir())
                     {
                         release();
                         ps_->redir(p.ps_);
                     }
-                    base::operator = (p);
-                }
+                base::operator = (p);
+
                 return * this;
             }
 
@@ -246,44 +244,6 @@
                 return operator = <T>(p);
             }
 
-//! FIXME
-#if 1
-        template <typename V>
-            shifted_ptr(V * p)
-            {
-                shifted<element_type> * const q = (typename shifted<element_type>::roofof) static_cast<element_type *>(rootof<is_polymorphic<element_type>::value>::get(p));
-
-                base::operator = (q);
-
-                if (! owned_base::pool_.is_from(this))
-                {
-                    ps_ = new set();
-
-                    init(q);
-                }
-                else
-                {
-                    owned_base::pool_.top(this)->ptrs()->push(& pn_);
-                    owned_base::pool_.top(this)->inits()->merge(* q->inits());
-                }
-            }
-
-        template <typename V>
-            shifted_ptr & operator = (V * p)
-            {
-                shifted<element_type> * const q = (typename shifted<element_type>::roofof) static_cast<element_type *>(rootof<is_polymorphic<element_type>::value>::get(p));
-
-                if (init())
-                {
-                    release();
-                    init(q);
-                }
-                base::operator = (q);
-
-                return * this;
-            }
-#endif
-
         void reset()
         {
             release();
@@ -295,11 +255,6 @@
         }
 
     private:
-        bool init()
-        {
-            return ps_ && ! owned_base::pool_.is_from(ps_);
-        }
-
         void release(bool d = false)
         {
             if (! owned_base::pool_.is_from(this))
@@ -313,7 +268,7 @@
                     else
                         delete ps_;
                 }
-                else
+                else 
                 {
                     base::reset();
 
@@ -327,18 +282,14 @@
 
         void init(owned_base * p)
         {
-            if (! p->init())
+            for (intrusive_list::iterator<owned_base, & owned_base::init_tag_> i = p->inits()->begin(), j; j = i, ++ j, i != p->inits()->end(); i = j)
             {
-                for (intrusive_list::iterator<owned_base, & owned_base::init_tag_> i = p->inits()->begin(), j; j = i, ++ j, i != p->inits()->end(); i = j)
+                ps_->elements()->push_back(i->set_tag());
+                
+                for (intrusive_stack::iterator<shifted_ptr, & shifted_ptr::pn_> m = i->ptrs()->begin(), n; n = m, ++ n, m != i->ptrs()->end(); m = n)
                 {
-                    ps_->elements()->push_back(i->set_tag());
-
-                    for (intrusive_stack::iterator<shifted_ptr, & shifted_ptr::pn_> m = p->ptrs()->begin(), n; n = m, ++ n, m != p->ptrs()->end() && ! m->init(); m = n)
-                        m->ps_ = ps_;
+                    m->ps_ = ps_;
                 }
-
-                p->init(true);
-                owned_base::pool_.construct().clear();
             }
         }
     };
Modified: sandbox/shifted_ptr/libs/smart_ptr/example/shifted_ptr_test2.cpp
==============================================================================
--- sandbox/shifted_ptr/libs/smart_ptr/example/shifted_ptr_test2.cpp	(original)
+++ sandbox/shifted_ptr/libs/smart_ptr/example/shifted_ptr_test2.cpp	2008-08-04 05:07:02 EDT (Mon, 04 Aug 2008)
@@ -65,7 +65,6 @@
     vector() { ++count; }
     ~vector() { --count; }
     vector(const vector& other) : elements(other.elements) { ++count; }
-
     //std::vector<shifted_ptr<vector> > elements;
     std::list<shifted_ptr<vector>, shifted_allocator< shifted_ptr<vector> > > elements; //! FIXME
 };
@@ -78,6 +77,7 @@
 };
 
 int main() {
+/*
     count = 0;
         {
             list l;
@@ -89,7 +89,14 @@
             }
         }
     std::cout << count << std::endl;
-
+*/
+    count = 0;
+    {
+        shifted_ptr<vector> v = new shifted<vector>();
+//        v->elements.push_back(v);
+    }
+    std::cout << count << std::endl;
+/*
     count = 0;
     {
         shifted_ptr<vector> v = new shifted<vector>();
@@ -97,14 +104,12 @@
     }
     std::cout << count << std::endl;
 
-    count = 0;
     {
         vector v;
         v.elements.push_back(new shifted<vector>());
     }
     std::cout << count << std::endl;
 
-/*
     count = 0;
     {
         shifted_ptr<int> test = new shifted<int>(5);
@@ -120,4 +125,5 @@
     }
     std::cout << count << std::endl;
 */
+    _exit(-1); // bypassing bug in pool destructor
 }