noexcept operator (desde C++11)
De cppreference.com
<metanoindex/>
O operador
noexcept executa uma verificação em tempo de compilação que retorna true se uma expressão for declarada a não lançar quaisquer exceções.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.
Ele pode ser usado dentro de
noexcept especificador
um modelo de função de declarar que a função irá lançar exceções para alguns tipos, mas não outros.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.
Original:
It can be used within a function template's
noexcept especificador
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.
Sintaxe
noexcept( expression )
|
|||||||||
Retorna um objeto do tipo
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.
Explicação
O operador
noexcept não avalia expression. O resultado é que o false expression contém pelo menos uma das seguintes construções potencialmente avaliados: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.
- ligar para qualquer tipo de função que não tem não jogando especificação de exceção, a menos que seja umexpressão constante.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.Original:call to any type of function that does not have non-throwing exception specification, unless it is aexpressão constante.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. throwexpressãoOriginal:throwexpressionThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.dynamic_castexpressão quando a conversão necessita de um tempo de execução de verificaçãoOriginal: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.typeidexpressão quando o tipo de argumento é do tipo classe polimórficaOriginal: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.
Em todos os outros casos, o resultado é
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.
Palavras-chave
Exemplo
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;
}
