Espaços nominais
Variantes
Acções

std::longjmp

Da cppreference.com
< cpp‎ | utility‎ | program

 
 
Biblioteca de utilitários
Digite apoio (basic types, RTTI, type traits)
Gerenciamento de memória dinâmica
De tratamento de erros
Utilidades do programa
Variadic funções
Data e hora
Objetos de função
(C++11)
Os operadores relacionais
Original:
Relational operators
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
rel_ops::operator!=
rel_ops::operator>
rel_ops::operator<=
rel_ops::operator>=
Pares e tuplas
Original:
Pairs and tuples
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
(C++11)
Troque, avançar e avançar
Original:
Swap, forward and move
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
(C++11)
(C++11)
(C++11)
 
Utilitários de apoio do programa
Término do programa
Original:
Program termination
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
(C++11)
(C++11)
Comunicando com o meio ambiente
Original:
Communicating with the environment
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Sinais
Original:
Signals
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Tipos de sinais
Original:
Signal types
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Não-locais saltos
Original:
Non-local jumps
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
longjmp
Tipos
Original:
Types
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
 
Definido no cabeçalho <csetjmp>
void longjmp( std::jmp_buf env, int status );
Carrega o env contexto de execução salvo por uma chamada anterior a setjmp. Esta função não retorna. O controle é transferido para o local chamado do setjmp macro que criou env. setjmp que retorna o valor, passado como o status.
Original:
Loads the execution context env saved by a previous call to setjmp. This function does not return. Control is transferred to the call site of the macro setjmp that set up env. That setjmp then returns the value, passed as the status.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Se a função que chamou setjmp foi encerrado, o comportamento é indefinido (em outras palavras, apenas saltos longos até a pilha de chamadas são permitidos)
Original:
If the function that called setjmp has exited, the behavior is undefined (in other words, only long jumps up the call stack are allowed)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Não destruidores para objetos automáticos são chamados. Se a substituição de std::longjmp com throw e setjmp com catch iria executar um destrutor não-trivial para qualquer objeto automático, o comportamento de tais std::longjmp é indefinido.
Original:
No destructors for automatic objects are called. If replacing of std::longjmp with throw and setjmp with catch would execute a non-trivial destructor for any automatic object, the behavior of such std::longjmp is undefined.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Índice

[editar] Parâmetros

env -
variável referente ao estado de execução do programa guardado por std::setjmp
Original:
variable referring to the execution state of the program saved by std::setjmp
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
status -
o valor para retornar de setjmp. Se for igual a 0, 1 é usado em vez disso
Original:
the value to return from setjmp. If it is equal to 0, 1 is used instead
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[editar] Valor de retorno

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

[editar] Exemplo

#include <iostream>
#include <csetjmp>
 
std::jmp_buf jump_buffer;
 
[[noreturn]] void a(int count) 
{
    std::cout << "a(" << count << ") called\n";
    std::longjmp(jump_buffer, count+1);  // setjump() will return count+1
}
 
int main()
{
    int count = setjmp(jump_buffer);
    if (count != 9) {
        a(count);  // This will cause setjmp() to exit
    }
}

Saída:

a(0) called
a(1) called
a(2) called
a(3) called
a(4) called
a(5) called
a(6) called
a(7) called
a(8) called

[editar] Veja também

salva o contexto
Original:
saves the context
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(função macro) [edit]
Documentação C para longjmp