boost::ptr_container: seems bug in erase_if

Hi! In ptr_sequence_adapter.hpp we have function: template< class Pred > void erase_if( iterator first, iterator last, Pred pred ) { range_check(first,last); this->base().erase( std::remove_if( first.base(), last.base(), void_ptr_delete_if<Pred,value_type>(pred) ), this->base().end() ); } If we call this function with second parameter not equal to this->base().end() then function remove not only elemets for wich pred return true, but also all alement from last.base() to the end of container (this->base().end()). This is seems bug due to function documentation: template< class Pred > void erase_if( Pred pred ); template< class Pred > void erase_if( iterator begin, iterator end, Pred pred ); * Requirements: Pred must take an const T& argument * Effects: removes all elements t for which pred(t) returns true from the entire container or the specified range -- Yours sincerely, Anton Ivanov (ai@drweb.com)

Anton Ivanov skrev:
Hi!
In ptr_sequence_adapter.hpp we have function:
template< class Pred > void erase_if( iterator first, iterator last, Pred pred ) { range_check(first,last); this->base().erase( std::remove_if( first.base(), last.base(),
void_ptr_delete_if<Pred,value_type>(pred) ), this->base().end() ); }
If we call this function with second parameter not equal to this->base().end() then function remove not only elemets for wich pred return true, but also all alement from last.base() to the end of container (this->base().end()).
Right. It should be last.base(). Thanks -Thorsten

Thorsten Ottosen ?????:
Anton Ivanov skrev:
Hi!
In ptr_sequence_adapter.hpp we have function:
template< class Pred > void erase_if( iterator first, iterator last, Pred pred ) { range_check(first,last); this->base().erase( std::remove_if( first.base(), last.base(),
void_ptr_delete_if<Pred,value_type>(pred) ), this->base().end() ); }
If we call this function with second parameter not equal to this->base().end() then function remove not only elemets for wich pred return true, but also all alement from last.base() to the end of container (this->base().end()).
Right. It should be last.base().
seems in 1.38.0 this bug is not fixed :( -- Yours sincerely, Anton Ivanov (ai@drweb.com) Unix Project Manager Doctor Web, Ltd.

Anton Ivanov skrev:
Thorsten Ottosen ?????:
Anton Ivanov skrev:
Hi!
In ptr_sequence_adapter.hpp we have function:
template< class Pred > void erase_if( iterator first, iterator last, Pred pred ) { range_check(first,last); this->base().erase( std::remove_if( first.base(), last.base(),
void_ptr_delete_if<Pred,value_type>(pred) ), this->base().end() ); }
If we call this function with second parameter not equal to this->base().end() then function remove not only elemets for wich pred return true, but also all alement from last.base() to the end of container (this->base().end()). Right. It should be last.base().
seems in 1.38.0 this bug is not fixed :(
Maybe I forgot to merge into the release. I'm sorry. -Thorsten

Thorsten Ottosen skrev:
Anton Ivanov skrev:
Thorsten Ottosen ?????:
Anton Ivanov skrev:
Hi!
seems in 1.38.0 this bug is not fixed :(
Maybe I forgot to merge into the release. I'm sorry.
Actually I did not even implement the fix in trunk. It's added to trunk in a few minutes. -Thorsten
participants (3)
-
Anton Ivanov
-
Thorsten Ottosen
-
Thorsten Ottosen