C++ ISO noexcept of noexcept

Having the noexcept(x) specifier in a function declaration means that the function is non-throwing if and only if x evaluates to true.

noexcept(y) can also be used as an operator, evaluating to true if y is a non-throwing expression, and to false if y can potentially throw.

Combined, this means void foo() noexcept(noexcept(y)); means: foo is non-throwing exactly when y is non-throwing.

In the case in the question, the function template swap for arrays is declared to be non-throwing if and only if swapping individual members of the arrays is non-throwing, which makes sense.

Leave a Comment

tech