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 }
Another thing for ptr_map_adapter is one of its Insert() overloads
std::pair
insert( key_type& key, value_type x ) I wonder why we don't use const key_type&? Without const modifier,
This is a known bug that is fixed in the cvs. the compiler would not allow passing constants to it. That is an exception-safety issue: if const key_type& was accepted, it could create a leak. In 1.34 you get a few other choices: std::auto_ptr<T> p( new T("arg1","arg2") ); map.insert( "key", p ); boost::assign::ptr_map_insert( map )( "key", "arg1", "arg2" );
At last, never forget to mention my environment: VC 8.0 No test has been done in other environment.
Please also check that the bug still exists in the cvs: http://www.boost.org/more/getting_started.html#CVS Thanks -Thorsten