VisualC ++ Exception Specifications
The word Exception Specifications is "abnormal specification". I don't know if it is accurate. I hope you can be more accurate.
The exception type is used to indicate the exceptions that a function can throw.
Function can throw any type of exception
void MyFunction(int i) throw(...);
Function cannot throw an exception
void MyFunction(int i) throw();
It is equivalent
void __declspec(nothrow) MyFunction(int i) throw();
Visual C ++ and Standard C ++ are implemented in the exception specification. The following describes the exception specification of Visual C ++.
Exception Specification |
Meaning |
Throw () |
The function does not throw an exception. |
Throw (...) |
Function can throw any exception |
Throw (type) |
The function throws a type exception. |
The behavior of a function to throw an exception also depends on the following factors:
Whether the function compilation method is C or C ++/EH is related to the specified exception specification (/EH: exception handling mode ).
The following is a detailed description:
Function |
/ESCs |
/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: For more information, see MSDN2008.