$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
From: 笨 笨 (imbenben_at_[hidden])
Date: 2006-03-03 21:30:58
Hi, all,
I'm a fresh hand to boost. I encounter some problems with ptr_map, in 
boost/ptr_container/detail/associative_ptr_container.hpp, line 107 & 111.
size_type erase( const key_type& x ) // nothrow
{
  BOOST_ASSERT( !this->empty() );       
  iterator i = find( x );                     // nothrow   // line 107
  if( i == this->end() )                      // nothrow
      return 0;                               // nothrow
  this->remove( i );                          // nothrow
  return this->c_private().erase( i.base() ); // nothrow   // line 111
}
In fact I doubt the correctness of these two lines. First, find() is 
defined in ptr_map_adapter class, which is a descendant of 
associative_ptr_container. No other find() functions could match the 
case here. As for the erase() in line 111, it's actually 
std::map::erase(). But this overload should return nothing as specified 
in C++ standard (in the case of MS implementation, it returns an 
iterator). In no way can it be converted to size_type. Simple 
modifications on the code could solve this problem.
Another thing for ptr_map_adapter is one of its Insert() overloads
std::pair<iterator,bool> insert( key_type& key, value_type x )
I wonder why we don't use const key_type&? Without const modifier, the 
compiler would not allow passing constants to it.
At last, never forget to mention my environment: VC 8.0
No test has been done in other environment.
-- Jason