Visualc++ Exception Specifications

Source: Internet
Author: User

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

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.