Weird behaviour/bug in ptr_map

Sorry if you get this twice, it didn't post for me on the first try. I was doing what I do regularly with std::maps... a m_plsts.erase( m_plsts.begin(), m_plsts.end() ); on a boost::ptr_map. It failed with an assertion error... Digging around, it came from ptr_container/detail/associative_ptr_container.hpp on line 117. It appears that every single erase (including that done by a key) has an assert for the map not being empty! Why is this the case? As far as I understand, it is valid to attempt to remove a key that does not exist. It follows that the same behaviour would occur whether the map was empty or not. Attempting to remove an element from an empty map should not result in an abort. If I'm unaware of some C++ convention I would love to be informed, however this definitely screams bug to me. Joshua Moore-Oliva

Joshua Moore-Oliva wrote:
Sorry if you get this twice, it didn't post for me on the first try.
I was doing what I do regularly with std::maps... a m_plsts.erase( m_plsts.begin(), m_plsts.end() ); on a boost::ptr_map. It failed with an assertion error... Digging around, it came from ptr_container/detail/associative_ptr_container.hpp on line 117. It appears that every single erase (including that done by a key) has an assert for the map not being empty!
Help me out here. The example does not work for m_plsts.empty() ?
Why is this the case? As far as I understand, it is valid to attempt to remove a key that does not exist. It follows that the same behaviour would occur whether the map was empty or not. Attempting to remove an element from an empty map should not result in an abort.
Sorry but how is this related to the above example? Thomas -- Thomas Witt witt@acm.org
participants (2)
-
Joshua Moore-Oliva
-
Thomas Witt