Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2007-12-11 11:00:11


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

> Thorsten Ottosen wrote:
>> I vote to accept this library. The documentation is very nice.
>
> Thanks for the vote.
>
>> 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"
>>
>> Under what cicumstances can/should/would I construct a ahsh or predicate
>> that throws? I mean, the hash computes an integer, and comparisons reads
>> data to determine its answer.
>>
>> This migth be what the standard requires, but it certainly seems
>> non-intuitive. Why not just require that neither hash nor predicates can
>> throw?
>
> The same could be said about Predicate for ordered containers like
> std::set/map. I haven't seen a practical case where the comparison could
> throw. But standard library experts should answer this better than me.
>
> 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.

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