"Malte Clasen"
Hi,
the erase() method (defined in associative_ptr_container.hpp, line 104) seems a bit strange:
size_type erase( const key_type& x ) // nothrow { BOOST_ASSERT( !this->empty() ); iterator i = find( x ); // nothrow if( i == this->end() ) // nothrow return 0; // nothrow this->remove( i ); // nothrow return this->c_private().erase( i.base() ); // nothrow }
My compiler (vc++7.1) complained about the unknown find() when I called erase() on ptr_map. "find" is not declared neither in this class nor in its base class. The closest valid call I could think of would be
this->c_private().find( x )
hm...maybe I overlooked something...I will look at that later.
. But there seems to be a nicer solution:
size_type erase( const key_type& x ) // nothrow { BOOST_ASSERT( !this->empty() ); return this->c_private().erase( x ); // nothrow }
This compiles fine and does just what I want it to do, even nothrow is guaranteed (I checked the vc++ reference for std::map). Now I wonder why erase() is implemented differently in Boost 1.33. Is there anything I overlooked?
deleting the object itself...not just the pointer.
Btw, is there a rationale for the declaration of insert()?
std::pair
insert( key_type& k, value_type x );
Passing key_type by non-const reference caused some unaesthetic constructs in my code because return values (temporaries) cannot be used directly.
indeed. but this is the only way to gain exception-safety. -Thorsten