Exception Specifications This word I become "abnormal specifications", do not know whether accurate, there is more accurate hope that everyone Brin stimulation oh.
The exception specification is used to indicate what kind of exception a function can throw.
function can throw any type of exception
function cannot throw an exception
It is equivalent to
void __declspec (nothrow) MyFunction (int i) throw ();
Visualc++ with standard C + + in exception specification, below is the exception specification for visualc++
Exception specifications |
Meaning |
Throw () |
function does not throw an exception |
Throw (...) |
function can throw any exception |
Throw (type) |
function throws type exception |
The behavior of a function that throws an exception also depends on the following factors:
- How to compile a function in C or C + +
- /EH compilation options (/EH: Exception handling Mode)
- The specified exception specification has a relationship
Here is a detailed description:
Function |
/EHsc |
/EHs |
/EHa |
/ehac |
C function |
Throw () |
Throw (...) |
Throw (...) |
Throw (...) |
C + + function with no exception specification |
Throw (...) |
Throw (...) |
Throw (...) |
Throw (...) |
C + + function with throw () exception specification |
Throw () |
Throw () |
Throw (...) |
Throw (...) |
C + + function with throw (...) exception specification |
Throw (...) |
Throw (...) |
Throw (...) |
Throw (...) |
C + + function with throw (type) exception specification |
Throw (...) |
Throw (...) |
Throw (...) |
Throw (...) |
P.S: The above contents refer to MSDN2008.
Visualc++ Exception Specifications