Boost logo

Boost :

From: Thorsten Ottosen (thorsten.ottosen_at_[hidden])
Date: 2007-12-11 11:45:30


David Abrahams skrev:
> on Fri Dec 07 2007, Ion Gaztañaga <igaztanaga-AT-gmail.com> wrote:
>
>> Thorsten Ottosen wrote:

>>> One thing puzzled me though:
>>> (see http://igaztanaga.drivehq.com/unordered/unordered/comparison.html)
>>>
>>> "The containers hash or predicate function can throw exceptions from erase"

>> Certainly, Daniel has tried to achieve strong exception guarantees and
>> the implementation becomes quite complicated if comparison/hash throws.
>> Double buffering and other tricks are needed. I think this is a very
>> good question both for boosters and people from the LWG.
>
> When specifying requirements in the standard, we (the LWG) don't like
> to constrain implementations or users if possible. I don't see any
> reason to forbid a throwing comparison or hash.

Right, but this is often a double-edged sword. Think of problems with
allowing std::list<T>::size() to be O(n).

What is flexibility for the implementer is often a synonym for
non-portability for the user. As a library implementer I have to be
conservative w.r.t. the exceotion-safety guarantees given which means
the additional guarantees given by some implementations cannot be taken
advantage of. Of course, I might take advantage of them in non-generic
code, but then at the expense of being non-portable.

-Thorsten


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