noexcept operator (C++11 起)
来自cppreference.com
|
|
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
noexcept运营商进行编译时检查,返回true,如果一个表达式被宣布为不抛出任何异常.Original:
The
noexcept operator performs a compile-time check that returns true if an expression is declared to not throw any exceptions.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Original:
It can be used within a function template's
noexcept说明</div> to declare that the function will throw exceptions for some types but not others.
Original:
noexcept specifier
The text has been machine-translated via [http://translate.google.com Google Translate].
You can help to correct and verify the translation. Click [http://en.cppreference.com/w/Cppreference:MachineTranslations here] for instructions.
You can help to correct and verify the translation. Click [http://en.cppreference.com/w/Cppreference:MachineTranslations here] for instructions.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
目录 |
[编辑] 语法
noexcept( expression )
|
|||||||||
返回对象类型bool
Original:
Returns an object of type bool.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[编辑] 解释
noexcept运营商不评估expression。 false如果expression包含以下可能评价的构造中的至少一个的结果是:Original:
The
noexcept operator does not evaluate expression. The result is false if the expression contains at least one of the following potentially evaluated constructs:The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
- .Original:call to any type of function that does not have non-throwing exception specification, unless it is a常量表达式</div>.Original:constant expressionThe text has been machine-translated via [http://translate.google.com Google Translate].
You can help to correct and verify the translation. Click [http://en.cppreference.com/w/Cppreference:MachineTranslations here] for instructions.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. -
throw表达Original:throwexpressionThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. -
dynamic_cast表达时的转换需要一个运行时检查Original:dynamic_castexpression when the conversion needs a run time checkThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. -
typeid表达时的参数类型是多态类的类型Original:typeidexpression when argument type is polymorphic class typeThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
- .
在所有其他情况下,结果是
true.Original:
In all other cases the result is
true.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[编辑] 关键字
[编辑] 为例
template <class T> void self_assign(T& t) noexcept(noexcept(T::operator=)) { // self_assign is noexcept if and only if T::operator= is noexcept t = t; }
[编辑] 另请参阅
| noexcept说明 | 需要一个函数不抛出任何异常(C++11)
Original: requires a function to not throw any exceptions (C++11) The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
| 异常规范 | 指定什么异常被抛出的功能(过时了)
Original: specifies what exceptions are thrown by a function (过时了) The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |