Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2003-10-08 19:20:12


Alexander Terekhov <terekhov_at_[hidden]> writes:

> David Abrahams wrote:
> [...]
>> We all agree that termination is appropriate when an invariant is
>> broken. What we don't agree on is the ability of outer-level calls to
>> determine that an invariant is broken based on the type of exception
>> thrown from an inner-level call. I believe that goes to the heart of
>> my objections to ESes.
>
> Well,
>
> <quote>
> Consider the following example (only slightly contrived).
>
> X get(int i) throw(out_of_range);
> int find(X& x) throw()
> {
> for (int i = 0; i < size(); ++i) {
> if (x == get(i)) return i;
> }
> return -1;
> }
>
> ....
>
> Maybe the programmer knows that the function will never be
> called, or that the path containing the throw statement will
> never be executed.
> ^
> </quote> |
> |
> .. if nothing goes wrong! --+
>
> http://www.bleading-edge.com/Publications/C++Report/v9607/Column2.rtf

Sure, this is an edge case.

Furthermore, my point is that it's almost impossible for the library
to add any unwinding actions which could interact badly with a problem
knowable only by the caller, and only at the point where the library
decides to throw.

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