Ordem de avaliação dos operandos de qualquer operador C + +, incluindo a ordem de avaliação de argumentos de função em uma expressão chamada de função, ea ordem de avaliação das subexpressões dentro de qualquer expressão não é especificado (exceto onde indicado abaixo). O compilador irá avaliá-los em qualquer ordem, e pode escolher outra ordem, quando a mesma expressão é avaliada novamente.
Original:
Order of evaluation of the operands of any C++ operator, including the order of evaluation of function arguments in a function-call expression, and the order of evaluation of the subexpressions within any expression is unspecified (except where noted below). The compiler will evaluate them in any order, and may choose another order when the same expression is evaluated again.
The text has been machine-translated via
Google Translate.
You can help to correct and verify the translation. Click
here for instructions.
Não existe o conceito de esquerda para a direita ou da direita para a esquerda de avaliação em C + +, o que não deve ser confundido com a esquerda para a direita e da direita para a esquerda associatividade de operadores: o
a + b + c
expressão é analisada como
(a + b) + c
devido a da esquerda para a direita associatividade de operador +, mas a
c
subexpressão pode ser avaliada primeiro (ou o último, ou ao mesmo tempo, como
a
ou
b
) em tempo de execução.
Original:
There is no concept of left-to-right or right-to-left evaluation in C++, which is not to be confused with left-to-right and right-to-left associativity of operators: the expression a + b + c
is parsed as (a + b) + c
due to left-to-right associativity of operator+, but the subexpression c
may be evaluated first (or last, or at the same time as a
or b
) at run time.
The text has been machine-translated via
Google Translate.
You can help to correct and verify the translation. Click
here for instructions.
[editar] Seqüenciados antes de rulesNJ
[editar] Definições
[editar] Avaliações
Existem dois tipos de avaliações realizadas pelo compilador para cada expressão ou subexpressão (ambos os quais são opcionais):
Original:
There are two kinds of evaluations performed by the compiler for each expression or subexpression (both of which are optional):
The text has been machine-translated via
Google Translate.
You can help to correct and verify the translation. Click
here for instructions.
-
'
Computação de valor: o cálculo do valor que é retornado pela expressão. Isso pode envolver a determinação da identidade do objeto (glvalue avaliação, por exemplo, se a expressão retorna uma referência a um objeto) ou ler o valor anteriormente atribuído a um objeto (avaliação prvalue, por exemplo, se a expressão retorna um número, ou algum outro valor ) Original:
value computation: calculation of the value that is returned by the expression. This may involve determination of the identity of the object (glvalue evaluation, e.g. if the expression returns a reference to some object) or reading the value previously assigned to an object (prvalue evaluation, e.g. if the expression returns a number, or some other value)
The text has been machine-translated via
Google Translate.
You can help to correct and verify the translation. Click
here for instructions.
-
'
Efeito colateral: o acesso (leitura ou gravação) para um objeto designado por um glvalue volátil, modificação (escrita) a um objeto, chamando uma biblioteca de função I / O, ou chamar uma função que faz qualquer uma dessas operações.Original:
side effect: access (read or write) to an object designated by a volatile glvalue, modification (writing) to an object, calling a library I/O function, or calling a function that does any of those operations.
The text has been machine-translated via
Google Translate.
You can help to correct and verify the translation. Click
here for instructions.
"Seqüenciado-antes" é uma assimétrica, em pares, transitivo relação entre as avaliações dentro da mesma linha (que pode estender-se entre segmentos se tipos atômicos estão envolvidos com
std::memory_order adequado).
Original:
"sequenced-before" is an asymmetric, transitive, pair-wise relationship between evaluations within the same thread (it may extend across threads if atomic types are involved with suitable std::memory_order).
The text has been machine-translated via
Google Translate.
You can help to correct and verify the translation. Click
here for instructions.
-
Se A é seqüenciado antes de B, então a avaliação de A será concluída antes da avaliação B começa.
Original:
If A is sequenced before B, then evaluation of A will be complete before evaluation of B begins.
The text has been machine-translated via
Google Translate.
You can help to correct and verify the translation. Click
here for instructions.
-
Se A não é seqüenciado antes de B e B é seqüenciado antes de A, de B, então a avaliação será concluída antes da avaliação A começa.
Original:
If A is not sequenced before B and B is sequenced before A, then evaluation of B will be complete before evaluation of A begins.
The text has been machine-translated via
Google Translate.
You can help to correct and verify the translation. Click
here for instructions.
-
Se A não é seqüenciado antes de B e B não é seqüenciado antes de A, então existem duas possibilidades:
Original:
If A is not sequenced before B and B is not sequenced before A, then two possibilities exist:
The text has been machine-translated via
Google Translate.
You can help to correct and verify the translation. Click
here for instructions.
* Avaliações de A e B são não seqüenciada: eles podem ser realizados em qualquer ordem e podem sobrepor (dentro de um único segmento de execução, o compilador pode intercalam as instruções da CPU que compreendem A e B)
Original:
* evaluations of A and B are unsequenced: they may be performed in any order and may overlap (within a single thread of execution, the compiler may interleave the CPU instructions that comprise A and B)
The text has been machine-translated via
Google Translate.
You can help to correct and verify the translation. Click
here for instructions.
* Avaliações de A e B são indeterminably-sequenciados: podem ser executadas em qualquer ordem, mas não podem sobrepor-se: ou A estará completa antes de B, ou B estará completa antes A. A ordem pode ser o oposto da próxima vez que a mesma expressão é avaliada.
Original:
* evaluations of A and B are indeterminably-sequenced: they may be performed in any order but may not overlap: either A will be complete before B, or B will be complete before A. The order may be the opposite the next time the same expression is evaluated.
The text has been machine-translated via
Google Translate.
You can help to correct and verify the translation. Click
here for instructions.
1)
Cada cálculo de valor e de efeitos secundários de uma expressão completa (uma expressão que não faz parte de outra expressão, tipicamente uma que termina com um ponto e vírgula) é sequenciado antes de cada cálculo de valor e dos efeitos colaterais da próxima expressão completa.
Original:
Each value computation and side effect of a full expression (an expression that is not part of another expression, typically one that ends with a semicolon) is sequenced before each value computation and side effect of the next full expression.
The text has been machine-translated via
Google Translate.
You can help to correct and verify the translation. Click
here for instructions.
2)
Os cálculos de valor (mas não os efeitos secundários) de operandos a qualquer operador são sequenciados antes do cálculo do valor do resultado do operador (mas não os seus efeitos colaterais).
Original:
The value computations (but not the side-effects) of the operands to any operator are sequenced before the value computation of the result of the operator (but not its side-effects).
The text has been machine-translated via
Google Translate.
You can help to correct and verify the translation. Click
here for instructions.
3)
Ao chamar uma função (ou não a função é inline, e se ou não a sintaxe de chamada explícita de função é usado), cada cálculo de valor e efeito colateral associado com qualquer expressão de argumento, ou com a expressão que designa o postfix função chamada, é seqüenciado antes execução de cada expressão ou instrução no corpo da função chamada.
Original:
When calling a function (whether or not the function is inline, and whether or not explicit function call syntax is used), every value computation and side effect associated with any argument expression, or with the postfix expression designating the called function, is sequenced before execution of every expression or statement in the body of the called function.
The text has been machine-translated via
Google Translate.
You can help to correct and verify the translation. Click
here for instructions.
4)
O cálculo do valor dos operadores nativos postincrement e postdecrement é seqüenciado antes de seu efeito colateral.
Original:
The value computation of the built-in postincrement and postdecrement operators is sequenced before its side-effect.
The text has been machine-translated via
Google Translate.
You can help to correct and verify the translation. Click
here for instructions.
5)
O efeito colateral do built-in pré-incremento e operadores predecrement é seqüenciado antes de seu cálculo de valor (regra implícita devido à definição de atribuição composto)
Original:
The side effect of the built-in preincrement and predecrement operators is sequenced before its value computation (implicit rule due to definition as compound assignment)
The text has been machine-translated via
Google Translate.
You can help to correct and verify the translation. Click
here for instructions.
6)
Cada valor de efeito de cálculo e do lado do argumento (à esquerda), antes de o built-in && lógicas e operador e do alto-operador lógico OR
Original:
The text has been machine-translated via
Google Translate.
You can help to correct and verify the translation. Click
here for instructions.
7)
Cada cálculo de valor e efeito colateral associado com a primeira expressão da lógica:? operador é sequenciado antes de cada cálculo de valor e efeito colateral associado com a expressão de segundo ou terceiro.
Original:
Every value computation and side effect associated with the first expression in the logical :? operator is sequenced before every value computation and side effect associated with the second or third expression.
The text has been machine-translated via
Google Translate.
You can help to correct and verify the translation. Click
here for instructions.
8)
O efeito colateral (modificação do argumento esquerdo) do operador de atribuição embutida e de todos embutidos operadores de atribuição compostos é sequenciado após o cálculo de valor (mas não os efeitos secundários) de ambos os argumentos para a esquerda e para a direita, e é sequenciado antes o cálculo do valor da expressão de atribuição (isto é, antes de voltar a referência para o objeto modificado)
Original:
The side effect (modification of the left argument) of the built-in assignment operator and of all built-in compound assignment operators is sequenced after the value computation (but not the side effects) of both left and right arguments, and is sequenced before the value computation of the assignment expression (that is, before returning the reference to the modified object)
The text has been machine-translated via
Google Translate.
You can help to correct and verify the translation. Click
here for instructions.
9)
Todo cálculo de valor e efeito colateral do argumento (à esquerda), antes de o operador vírgula embutido é seqüenciado antes de cada cálculo de valor e efeito colateral do argumento (direita).
Original:
Every value computation and side effect of the first (left) argument of the built-in comma operator is sequenced before every value computation and side effect of the second (right) argument.
The text has been machine-translated via
Google Translate.
You can help to correct and verify the translation. Click
here for instructions.
10)
Em
lista de inicialização, cada valor de efeito de cálculo e do lado de uma cláusula inicializador dado é seqüenciado antes de cada cálculo de valor e efeito colateral associado com qualquer cláusula inicializador que se segue na lista separada por vírgulas da lista de inicializador.
Original:
In
lista de inicialização, every value computation and side effect of a given initializer clause is sequenced before every value computation and side effect associated with any initializer clause that follows it in the comma-separated list of the initializer list.
The text has been machine-translated via
Google Translate.
You can help to correct and verify the translation. Click
here for instructions.
11)
A chamada de função que não é sequenciado antes ou depois sequenciados outra chamada de função é indeterminadamente sequenciado (o programa deve comportar
as if as instruções da CPU que constituem as chamadas de funções diferentes, não foram intercalados, mesmo que as funções foram sequenciados)
Original:
A function call that is not sequenced before or sequenced after another function call is indeterminately sequenced (the program must behave
as if the CPU instructions that constitute different function calls were not interleaved, even if the functions were inlined)
The text has been machine-translated via
Google Translate.
You can help to correct and verify the translation. Click
here for instructions.
12)
A chamada para a função de alocação (operador de novo) é indeterminadamente seqüenciado com relação à avaliação dos argumentos do construtor em uma expressão nova
Original:
The call to the allocation function (operator new) is indeterminately sequenced with respect to the evaluation of the constructor arguments in a new-expression
The text has been machine-translated via
Google Translate.
You can help to correct and verify the translation. Click
here for instructions.
[editar] Comportamento indefinido
1)
Se um efeito secundário de um objecto não seqüenciada escalar é relativa a um outro efeito secundário sobre o objecto escalar mesmo, o comportamento é indefinido.
Original:
If a side effect on a scalar object is unsequenced relative to another side effect on the same scalar object, the behavior is undefined.
The text has been machine-translated via
Google Translate.
You can help to correct and verify the translation. Click
here for instructions.
i = ++i + i++; // undefined behavior
i = i++ + 1; // undefined behavior (but i = ++i + 1; is well-defined)
f(++i, ++i); // undefined behavior
f(i = -1, i = -1); // undefined behavior
2)
Se um efeito secundário de um objecto não seqüenciada escalar é relativa a um cálculo de valor com o valor do objecto escalar mesmo, o comportamento é indefinido.
Original:
If a side effect on a scalar object is unsequenced relative to a value computation using the value of the same scalar object, the behavior is undefined.
The text has been machine-translated via
Google Translate.
You can help to correct and verify the translation. Click
here for instructions.
cout << i << i++; // undefined behavior
a[i] = i++; // undefined bevahior
[editar] RulesNJ ponto de seqüência
[editar] Definições
Avaliação de uma expressão pode produzir efeitos colaterais, que são: acessar um objeto designado por um lvalue volátil, modificando um objeto, chamando uma biblioteca de função I / O, ou chamar uma função que faz qualquer uma dessas operações.
Original:
Evaluation of an expression might produce side effects, which are: accessing an object designated by a volatile lvalue, modifying an object, calling a library I/O function, or calling a function that does any of those operations.
The text has been machine-translated via
Google Translate.
You can help to correct and verify the translation. Click
here for instructions.
A'
ponto sequência é um ponto em que a sequência de execução de todos os efeitos secundários das avaliações anteriores na sequência estão completas, e sem efeitos colaterais das avaliações subsequentes começou.Original:
A sequence point is a point in the execution sequence where all side effects from the previous evaluations in the sequence are complete, and no side effects of the subsequent evaluations started.
The text has been machine-translated via
Google Translate.
You can help to correct and verify the translation. Click
here for instructions.
1)
Há um ponto de sequência no final de cada expressão completa (tipicamente, no ponto e vírgula)
Original:
There is a sequence point at the end of each full expression (typically, at the semicolon)
The text has been machine-translated via
Google Translate.
You can help to correct and verify the translation. Click
here for instructions.
2)
Ao chamar uma função (ou não a função é inline e se ou não a sintaxe chamada de função foi usado), há um ponto de seqüência após a avaliação de todos os argumentos da função (se houver) que ocorre antes da execução de quaisquer expressões ou declarações em o corpo da função
Original:
When calling a function (whether or not the function is inline and whether or not function call syntax was used), there is a sequence point after the evaluation of all function arguments (if any) which takes place before execution of any expressions or statements in the function body
The text has been machine-translated via
Google Translate.
You can help to correct and verify the translation. Click
here for instructions.
3)
Há um ponto de sequência após a cópia de um valor retornado de uma função e, antes da execução de qualquer manifestação fora da função.
Original:
There is a sequence point after the copying of a returned value of a function and before the execution of any expressions outside the function.
The text has been machine-translated via
Google Translate.
You can help to correct and verify the translation. Click
here for instructions.
4)
Uma vez que a execução de uma função começa, não há expressões da função de chamada são avaliados até a execução da função chamada foi concluída (funções não podem ser intercalados)
Original:
Once the execution of a function begins, no expressions from the calling function are evaluated until execution of the called function has completed (functions cannot be interleaved)
The text has been machine-translated via
Google Translate.
You can help to correct and verify the translation. Click
here for instructions.
5)
Na avaliação de cada um dos seguintes quatro expressões, usando os embutidos (não sobrecarregado) operadores, há um ponto de sequência após a avaliação da expressão
a
.
Original:
In the evaluation of each of the following four expressions, using the built-in (non-overloaded) operators, there is a sequence point after the evaluation of the expression a
.
The text has been machine-translated via
Google Translate.
You can help to correct and verify the translation. Click
here for instructions.
a && b
a || b
a ? b : c
a , b
[editar] Comportamento indefinido
1)
Entre o ponto de sequência anterior e seguinte, um objeto escalar deve ter um valor armazenado modificado no máximo uma vez por meio da avaliação de uma expressão.
Original:
Between the previous and next sequence point a scalar object shall have its stored value modified at most once by the evaluation of an expression.
The text has been machine-translated via
Google Translate.
You can help to correct and verify the translation. Click
here for instructions.
i = ++i + i++; // undefined behavior
i = i++ + 1; // undefined behavior
i = ++i + 1; // undefined behavior (well-defined in C++11)
++ ++i; // undefined behavior (well-defined in C++11)
f(++i, ++i); // undefined behavior
f(i = -1, i = -1); // undefined behavior
2)
Entre o ponto de sequência anterior e seguinte, o valor anterior de um objeto escalar que é modificada por meio da avaliação da expressão, deve ser acedida apenas para determinar o valor a ser armazenado.
Original:
Between the previous and next sequence point , the prior value of a scalar object that is modified by the evaluation of the expression, shall be accessed only to determine the value to be stored.
The text has been machine-translated via
Google Translate.
You can help to correct and verify the translation. Click
here for instructions.
cout << i << i++; // undefined behavior
a[i] = i++; // undefined bevahior
[editar] Veja também
-
Precedência do operador que define como expressões são criadas a partir de sua representação de código fonte.
Original:
The text has been machine-translated via
Google Translate.
You can help to correct and verify the translation. Click
here for instructions.
-
Ordem de avaliação na linguagem de programação C.
Original:
The text has been machine-translated via
Google Translate.
You can help to correct and verify the translation. Click
here for instructions.