Re: Exceptions, Go to Hell!
Goran Pusic <email@example.com> wrote:
On Aug 24, 9:36?am, ?? Tiib <oot...@hot.ee> wrote:
STL does throw on bugs. If you do not have bugs then it does not
That's too simplified. It throws on failed allocations and of course,
it does not try to be smart with exceptions from assignment operators
or copy constructors for user types.
Frankly, I agree with ?? Tiib. It has been my experience that if my
program threw an exception, any exception, I had to re-write it so that
it no longer threw the exception.
[From Goran in a different post]
typically, what happens is that code embarks on some path, allocates,
calculates (rinse, repeat)... When done, it cleans up whatever is
auxiliary and keeps some form of result (even if it is some
modification of the global state. Now... If said code path ends
happily, there probably was a peak on resource usage somewhere in the
middle, and then, when going back some of these resources were freed
(any temporary resources). If code path steps on resource shortage, it
has to go up the stack (or better yet, I should say something like
"resource allocation chain") and free any resources it obtained in the
If the code's result is required for proper program functioning, and it
fails (throws an exception,) then the code has to be re-written so that
it won't fail anymore. If the code's result isn't required, then why
call the code in the first place?
I guess you could write a program that provides extra features if enough
memory happens to be available, but I've never had to do that, nor have
I seen a program that does.