Namespaces
Variants
Views
Actions

exception specification

From cppreference.com
< cpp‎ | language
Revision as of 05:47, 2 November 2011 by Cubbi (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Template:cpp/language/sidebar

Lists the exceptions that a function might directly or indirectly throw.

Syntax

throw(Template:sparam) (1) (deprecated)
noexcept(Template:sparam) (2) Template:mark c++11 feature

Explanation

1) If a function is declared with type T listed in its exception specification, the function may throw exceptions of that type or a type derived from it.

If the function throws an exception of the type not listed in its exception specification, the function Template:cpp is called. The default function calls Template:cpp, but it may be replaced by a user-provided function which may call Template:cpp or throws an exception. If the exception thrown from Template:cpp is accepted by the exception specification, stack unwinding continues as usual. If it isn't, but Template:cpp is allowed by the exception specification, Template:cpp is thrown. Otherwise, Template:cpp is called:

Template:example cpp

2) see noexcept specifier