Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2007-12-12 13:06:23


on Tue Dec 11 2007, Joaquín Mª López Muñoz <joaquin-AT-tid.es> wrote:

> David Abrahams ha escrito:
>
>> on Sun Dec 09 2007, Ion Gaztañaga <igaztanaga-AT-gmail.com> wrote:
>>
>> >
>> > 23.1.3.1 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.

-- 
Dave Abrahams
Boost Consulting
http://www.boost-consulting.com

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk