noexcept

noexcept operator (since C++11) - cppreference.com https://en.cppreference.com/w/cpp/language/noexcept

noexcept operator (since C++11)

The noexcept operator performs a compile-time check that returns true if an expression is declared to not throw any exceptions.

It can be used within a function template's noexcept specifier to declare that the function will throw exceptions for some types but not others.

Syntax

 
noexcept( expression )    
 

Returns a prvalue of type bool. The result is true if the set of potential exceptions of the expression is empty(until C++17)expression is non-throwing(since C++17), and false otherwise.

expression is an unevaluated operand.

If expression is a prvalue, temporary materialization is formally applied. Particularly, the destructor is required to be non-deleted and accessible if such expression is of a class type or (possibly multidimensional) array thereof.

(since C++17)

Keywords

noexcept

Notes

Evaluation of a non-throwing expression is allowed to throw an exception if the evaluation has undefined behavior.

 

 

 

 

posted @ 2024-01-11 18:32  papering  阅读(2)  评论(0编辑  收藏  举报