A C++ keyword used for exception-specifications and to query whether an expression can throw exceptions
When used at the end of a function declaration noexcept(constant)opt
indicates whether or not a function can throw exceptions, replacing the deprecated C++03 form of exception specification using throw(…)
. If the constant expression in parentheses evaluates to true
(or if the parentheses are omitted) it indicates the function will not throw, otherwise it indicates it might throw.
When used as an operator noexcept( expr )
does not evaluate the expression but returns a boolean indicating whether the expression cannot throw exceptions.
Use this tag for questions about either use of the noexcept
keyword.
For the history and rationale of noexcept
see Using noexcept