Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++11, `noexcept` specifier, definition versus declaration

Tags:

If a declared function has a noexcept specificator (noexcept, noexcept(true), noexcept(false), or any other noexcept(expr) which evaluates to true or false), but it's defined in another place, do I need to specify the noexcept specifier in the definition again, or only in its forward declaration?

like image 990
Peregring-lk Avatar asked Apr 21 '15 15:04

Peregring-lk


1 Answers

[except.spec]/p4:

If any declaration of a function has an exception-specification that is not a noexcept-specification allowing all exceptions, all declarations, including the definition and any explicit specialization, of that function shall have a compatible exception-specification.

noexcept(some-constant-expression-that-evaluates-to-false) may be omitted. Anything else must be present in all declarations.

like image 90
T.C. Avatar answered Sep 22 '22 05:09

T.C.