Espaços nominais
Variantes
Acções

setjmp

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.
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.
setjmp
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>
#define setjmp(env) /* implementation-defined */
Salva o contexto de execução atual em um env variável de std::jmp_buf tipo. Esta variável pode ser usado posteriormente para restaurar o contexto de execução atual por função std::longjmp. Isto é, quando uma chamada de função std::longjmp é feito, a execução continua com o local de chamada especial, que a variável construída std::jmp_buf passado para std::longjmp. Nesse caso, os retornos setjmp valor tho passado para std::longjmp.
Original:
Saves the current execution context into a variable env of type std::jmp_buf. This variable can later be used to restore the current execution context by std::longjmp function. That is, when a call to std::longjmp function is made, the execution continues at the particular call site that constructed the std::jmp_buf variable passed to std::longjmp. In that case setjmp returns tho value passed to std::longjmp.
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 para guardar o estado de execução do programa a .
Original:
variable to save the execution state of the program to.
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

0 se a macro foi chamado pelo código original e o contexto de execução foi salvo env.
Original:
0 if the macro was called by the original code and the execution context was saved to env.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Valor diferente de zero se um salto não-local estava realizada. O valor de retorno no mesmo passado para std::longjmp.
Original:
Non-zero value if a non-local jump was just performed. The return value in the same as passed to std::longjmp.
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

salta para local especificado
Original:
jumps to specified location
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(função)[edit]
Documentação C para setjmp
close