Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r51306 - in trunk/boost/ptr_container: . detail
From: nesotto_at_[hidden]
Date: 2009-02-17 17:42:04


Author: nesotto
Date: 2009-02-17 17:42:04 EST (Tue, 17 Feb 2009)
New Revision: 51306
URL: http://svn.boost.org/trac/boost/changeset/51306

Log:
removed nasty bug in erase()
Text files modified:
   trunk/boost/ptr_container/detail/reversible_ptr_container.hpp | 6 ++++++
   trunk/boost/ptr_container/ptr_set_adapter.hpp | 10 ++++++----
   2 files changed, 12 insertions(+), 4 deletions(-)

Modified: trunk/boost/ptr_container/detail/reversible_ptr_container.hpp
==============================================================================
--- trunk/boost/ptr_container/detail/reversible_ptr_container.hpp (original)
+++ trunk/boost/ptr_container/detail/reversible_ptr_container.hpp 2009-02-17 17:42:04 EST (Tue, 17 Feb 2009)
@@ -238,6 +238,12 @@
             sd.release();
         }
 
+ template< class U >
+ void remove( U* ptr )
+ {
+ null_policy_deallocate_clone( ptr );
+ }
+
         template< class I >
         void remove( I i )
         {

Modified: trunk/boost/ptr_container/ptr_set_adapter.hpp
==============================================================================
--- trunk/boost/ptr_container/ptr_set_adapter.hpp (original)
+++ trunk/boost/ptr_container/ptr_set_adapter.hpp 2009-02-17 17:42:04 EST (Tue, 17 Feb 2009)
@@ -204,12 +204,14 @@
         
         size_type erase( const key_type& x ) // nothrow
         {
- iterator i( this->base().find( const_cast<key_type*>(&x) ) );
- // nothrow
+ key_type* key = const_cast<key_type*>(&x);
+ iterator i( this->base().find( key ) );
             if( i == this->end() ) // nothrow
                 return 0u; // nothrow
- this->remove( i ); // nothrow
- return this->base().erase( const_cast<key_type*>(&x) ); // nothrow
+ key = static_cast<key_type*>(*i.base()); // nothrow
+ size_type res = this->base().erase( key ); // nothrow
+ this->remove( key ); // nothrow
+ return res;
         }
 
 


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk