Boost logo

Boost Users :

Subject: Re: [Boost-users] [Multi-Index] Design Rationale behind erase in ordered_index container
From: Etienne Pretorius (icewolfhunter_at_[hidden])
Date: 2012-02-21 10:33:29


Probably so that you may selectively erase elements within a loop based on some criteria.

Kind Regards,
Etienne Pretorius

On 21 Feb 2012, at 5:29 PM, Ovanes Markarian wrote:

> Hello Joaquín,
>
> the doc states in erase that an iterator or end-iterator is returned when erasing an element. What was the rationale behind returning the iterator? Where other members return the number of elements being removed.
>
> My point is that end-iterator is also returned when erasing an element where iterator points one before the end iterator. Now to be sure that the specified element was really removed my call must either use the key and search for that element again or compare the size before and after the erase call.
>
>
> Many thanks,
> Ovanes
>
> http://www.boost.org/doc/libs/1_47_0/libs/multi_index/doc/reference/ord_indices.html#synopsis
>
> iterator erase(iterator position);
> Requires: position is a valid dereferenceable iterator of the index.
> Effects: Deletes the element pointed to by position.
> Returns: An iterator pointing to the element immediately following the one that was deleted, or end() if no such element exists.
> Complexity: O(D(n)).
> Exception safety: nothrow.
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net