* Stefan Pantos <st***********@chem.ox.ac.uk> schriebt:
Could someone explain to me the proper use of throw()? As it is used
for std::exception. I cannot find anything which describes how it should
be used and all the information about exceptions in c++ seem to ignore
it completly. I know that it's similar to throws in java but I have no
idea of how it should be used.
When I say throw() I mean in the way it is used here:
class exception
{
public:
exception() throw() { }
virtual ~exception() throw();
/** Returns a C-style character string describing the general cause
* of the current error. */
virtual const char* what() const throw();
} };
That's an exception specification.
Java is based on static checking of exception specifications, whereas C++ is
based on dynamic checking.
That means essentially that the only exception specifications that are of
value in C++ are those where you definitely want the program to abort when or
if the specification is violated. 'throw()' is useful, and 'throw(
std::exception )' _can_ be useful, but opinions differ. Anything else should
probably be avoided.
--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?