Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2007-12-12 07:44:59


on Tue Dec 11 2007, Thorsten Ottosen <thorsten.ottosen-AT-dezide.com> wrote:

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

Or allowing ptr_container<T> to not be assignable and
copy-constructible?

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

I'm aware of all the tradeoffs. It's a balancing act, as ever.

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