Re: [Boost-users] [1.33][ptr_container] bug in erase() in associative containers?
----- Mensaje original -----
De: Thorsten Ottosen
"JOAQUIN LOPEZ MU?Z"
wrote in message news:1553a314f2df.14f2df1553a3@tid.es... size_type erase( const key_type& x ) // nothrow { BOOST_ASSERT( !this->empty() );
Why the BOOST_ASSERT? Do you require that the container be non-empty for erase to be callable? Am I missing something?
>
Hm...I couldn't find anything on this in the standard. Can you locate the description for map
::erase( const K&) ?
In 23.1.2 [lib.associative.reqmts], the table has an entry for the expression "a.erase(k)" saying: "erases all the elements in the container with key equivalent to k. returns the number of erased elements." No precondition is stated that "a" should be nonempty, neither in the table itself nor in the general requisites for the table (23.1.2/7), hence "a" is allowed to be empty. I've taken a closer look at your code and think there are some more of these overzealous asserts: * The following in associative_ptr_container.hpp iterator erase( iterator first, iterator last ) // nothrow { BOOST_ASSERT( !this->empty() ); requires again that the container be nonempty. There's no such precondition in the std for the expression "a.erase(q1,q2)": the only requisite in 23.1.2/7 is that [q1, q2) be a valid range, which is compatible with "a" being empty if q1==q2==a.end() (see 24.1/7, see also DR151 which addresses an issue with the original erroneous requirement that q1 be dereferenceable). * Same problem as above in reversible_ptr_container.hpp. HTH, Joaquín M López Muñoz Telefónica, Investigación y Desarrollo
"JOAQUIN LOPEZ MU?Z"
>>>
Fixed in cvs. Thanks. -Thorsten
participants (2)
-
JOAQUIN LOPEZ MU?Z
-
Thorsten Ottosen