|
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 <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.
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 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