|
Boost : |
From: JOAQUIN LOPEZ MU?Z (joaquin_at_[hidden])
Date: 2007-12-11 14:25:04
----- Mensaje original -----
De: Daniel James <daniel_james_at_[hidden]>
Fecha: Martes, Diciembre 11, 2007 8:01 pm
Asunto: Re: [boost] [review] Review of Unordered library begins today
December7
Para: boost_at_[hidden]
> Joaquín Mª López Muñoz wrote:
> > 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 (incidentally, the
> > implications of rehashing when erasing a range would be
> > difficult to cope with).
> >
>
> If a container implemented a rehash which doesn't invalidate
> iterators
> (which is certainly possible, if unlikely) then could it rehash?
> (Of course, such a container would have to maintain the order of the
> elements).
I don't think so: even if you manage to implement an
iterator-conscious, order-preserving, sensible rehashing mechanism,
getting new memory can throw std::bad_alloc, which is not allowed
(only throwing from Hash or Pred permitted)--unless you catch
such exceptions internally... but this is rather artificial. My
opinion is that the writers of this piece of the C++0x standard
didn't consider rehashing as a permissible operation when
erasing.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk