Re: Place Assert in Exception
James Kanze <james.kanze@gmail.com> wrote:
"Daniel T." <danie...@earthlink.net> wrote:
Immortal Nephi <Immortal_Ne...@hotmail.com> wrote:
Please tell me what you think Error_Report class? Is throw
better than abort()?
If you are writing a library that others will be using, then
it is not up to you to decide to summarily abort their app.
Yes and no. If they violate the contract of your library,
summarily terminating their application is probably the best
solution (in most applications).
Again, I don't see where that is up to you since you are not the
application writer and you don't know if the particular application that
your library is being used in qualifies under the phrase "most
applications" or if this particular situation is a special case.
Note that assert is never used by the standard library;
Really? It is in the implementations I'm familiar with.
Anytime the library detects you've done something that the
standard specifies is undefined behavior.
Asserts may very well be used in particular implementations of the
standard library, where the standard doesn't specify the result of an
operation, but the standard itself never specifies that doing X will
cause an assert to fire, but it does make such specifications about
exceptions.