VisualC ++ Exception Specifications

Source: Internet
Author: User

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.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.