Boost logo

Boost :

From: Eric Niebler (eric_at_[hidden])
Date: 2007-12-12 13:14:16

David Abrahams wrote:
> on Tue Dec 11 2007, Joaquín Mª López Muñoz <> wrote:
>> David Abrahams ha escrito:
>>> on Sun Dec 09 2007, Ion Gaztañaga <> wrote:
>>>> Exception safety guarantees [unord.req.except]
>>>> 1 For unordered associative containers, no clear() function throws an
>>>> exception. No erase() function throws an exception unless that exception
>>>> is thrown by the container’s Hash or Pred object (if any).
>>>> Why this difference? I hope someone knows the answer ;-)
>>> Because unordered associative containers may rehash when erasing.
>> I think unordered containers are *not* allowed to rehash when erasing:
>> see N2461, 23.1.3/8
>> "...Rehashing invalidates iterators, changes ordering between elements,..."
>> and 23.1.3/12
>> "...The erase members shall invalidate only iterators and references
>> to the erased elements."
>> so the conclusion is that erase can't rehash
> Sorry, how do you reach that conclusion? It says that erase can
> invalidate iterators, and the only thing it says that rehashing
> invalidates is iterators.

If I'm understanding correctly, erase can only invalidate iterators (to
the erased elements*, but rehashing invalidates iterators to all
elements. Therefor, erase cannot rehash. Did I get that right?

Eric Niebler
Boost Consulting

Boost list run by bdawes at, gregod at, cpdaniel at, john at