Re: Unhandled exception - How to turn off!
- From: "Vladimir Nesterovsky" <vladimir@xxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 22 Mar 2007 08:42:56 +0200
bad_cast,
bad_exception,
bad_typeid,
terminate,
type_info,
uncaught_exception,
unexpected
all these functions and classes are deeply language bounded, and reside
in the std namespace.
Yes, in some cases the compiler implicitly calls std library functions,
such as uncaught_exception or unexpected. The compiler has every right to
generate implicit function calls. Those two functions, however, are the
dark side of C++, and the general consensus is that it's better to avoid
them. I wouldn't touch uncaught_exception or exception specifiers with a
10-foot pole:
http://www.gotw.ca/gotw/047.htm
http://www.gotw.ca/gotw/082.htm
A valid use of uncaught_exception function is in the RAII e.g:
class TransactionScope
{
private:
Connection &connection;
public:
TransactionScope(Connection &connection): connection(connection)
{
connection.BeginTransaction();
}
~TransactionScope()
{
if (!std::uncaught_exception())
connection.Commit();
else
connection.Rollback();
}
};
....
Connection &connection = ...
{
TransactionScope transactionScope(connection);
...
}
....
--
Vladimir Nesterovsky
.
- References:
- Unhandled exception - How to turn off!
- From: David F.
- Re: Unhandled exception - How to turn off!
- From: Ben Voigt
- Re: Unhandled exception - How to turn off!
- From: Ulrich Eckhardt
- Re: Unhandled exception - How to turn off!
- From: Ben Voigt
- Re: Unhandled exception - How to turn off!
- From: Ulrich Eckhardt
- Re: Unhandled exception - How to turn off!
- From: Ben Voigt
- Re: Unhandled exception - How to turn off!
- From: Vladimir Nesterovsky
- Re: Unhandled exception - How to turn off!
- From: Tamas Demjen
- Unhandled exception - How to turn off!
- Prev by Date: Re: question regarding using memcpy
- Next by Date: Re: Strange code generated by compiler
- Previous by thread: Re: Unhandled exception - How to turn off!
- Next by thread: Re: Unhandled exception - How to turn off!
- Index(es):
Relevant Pages
|