◐ Shell
clean mode source ↗

noexcept operator (desde C++11) - cppreference.com

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.

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.

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.

  • throw expressão

    Original:

    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.

  • dynamic_cast expressão quando a conversão necessita de um tempo de execução de verificação

    Original:

    dynamic_cast expression when the conversion needs a run time check

    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.

  • typeid expressão quando o tipo de argumento é do tipo classe polimórfica

    Original:

    typeid expression when argument type is polymorphic class type

    The 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.

Palavras-chave

noexcept

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;
}

Veja também

noexcept especificador

requer uma função para não jogar qualquer (C++11) exceções

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.

[edit]
especificação de exceção

especifica que as exceções são lançadas por um (obsoleta) função

Original:

specifies what exceptions are thrown by a function (obsoleta)

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[edit]