名前空間
変種
操作

Order of evaluation

提供: cppreference.com
< cpp‎ | language

 
 
C + +言語
一般的なトピック
Original:
General topics
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
フロー制御
Original:
Flow control
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
条件付き実行文
Original:
Conditional execution statements
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
繰り返し文
Original:
Iteration statements
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
文をジャンプします
Original:
Jump statements
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
機能します
Original:
Functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
関数の宣言
ラムダ関数の宣言
関数テンプレート
の歴史。インライン指定
例外仕様 (廃止予定)
noexcept指定子 (C++11)
例外
Original:
Exceptions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
名前空間
Original:
Namespaces
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
タイプ
Original:
Types
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
decltype specifier (C++11)
指定子
Original:
Specifiers
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
CV指定
貯蔵期間指定
constexprの指定子 (C++11)
自動指定 (C++11)
alignas指定子 (C++11)
初期化
Original:
Initialization
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
リテラル
Original:
Literals
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Original:
Expressions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
値カテゴリ
評価の順序
代替表現
ユーティリティ
Original:
Utilities
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
タイプ
Original:
Types
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
typedef declaration
型の別名宣言 (C++11)
属性 (C++11)
キャストします
Original:
Casts
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
暗黙の型変換
const_cast conversion
static_cast conversion
dynamic_cast conversion
reinterpret_cast conversion
Cスタイルキャストと機能
メモリの割り当て
Original:
Memory allocation
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
クラス
Original:
Classes
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
クラス固有の機能特性
Original:
Class-specific function properties
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
明示 (C++11)
静的
特殊なメンバ関数
Original:
Special member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
テンプレート
Original:
Templates
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
クラステンプレート
関数テンプレート
テンプレートの特殊化
パラメーターパック (C++11)
その他
Original:
Miscellaneous
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
インラインアセンブリ
 
任意の式の中の関数呼び出し式の中で関数の引数の評価順序を含む、任意のC + +の演算子や、部分式の評価の順序のオペランドの評価順序(以下を特に明記する場合を除く)特定されていません。コンパイラは、任意の順序でそれらを評価し、同じ式が再び評価されるときに別の注文を選択することができます.
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.
で左から右または右から左への評価という概念はありませんC + +で、これは、演算子の左から右へ、右から左結合と混同しないようにします:式a + b + c(a + b) + c原因として解析されますに左から右への+演算子の結合性が、部分式cは、実行時に(あるいは最後、またはまたはab同時に)、最初に評価することができる.
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.

目次

[編集] 配列を決定し、前rulesNJ

[編集] 定義

[編集] 評価

それぞれの表現あるいはその部分式(オプションですどちらも)のためにコンパイラによって実行評価の2種類があります
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.
  • の値の計算:式によって返される値の計算。これは、オブジェクトの同一性の決定(glvalue評価は、式がいくつかのオブジェクトへの参照を返す場合など)を含むか、または式が数値、またはいくつかの他の値を返した場合、以前のオブジェクト(prvalue評価などに割り当てられている値を読み取ることができる)
    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.
  • 副作用:オブジェクトへの揮発性glvalueによって指定されたオブジェクトへのアクセス権(読み取りまたは書き込み)、変更(書き込み)、ライブラリのI / O関数を呼び出すこと、またはこれらのいずれかの操作を行う関数を呼び出す.
    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.

[編集] オーダー

"シークエンス·前"とは、同じスレッド内での評価との間に非対称、他動詞、ペアワイズの関係(原子タイプが適しstd::memory_orderに関与している場合、それは、スレッド間で延長することができる)です.
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.
  • Bの前に配列決定されている場合はBの評価が開始される前に、その後の評価は完全なものとなる.
    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.
  • BとBが前に配列決定される前に、配列決定されていない場合の評価を開始する前に、Bの評価が完了します.
    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.
  • BとBが前に配列決定されていない前に、配列決定されていない場合は、二つの可能性が存在します
    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.
  • AとBの*評価は、非配列されています:彼らは(単一の実行スレッド内では、コンパイラはAとBを構成するCPU命令をインターリーブすることがあります)どのような順序で実行されてもよいと重なるかもしれません
    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.
  • AとBの*評価がindeterminably順です:彼らはどのような順序で実行されてもよいが重複してはなりません:どちらかBの前に完全なものとなり、Aのいずれかの順序が同じ次回反対かもしれない前に、Bが完全なものとなる式が評価され.
    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)
フル式(通常はセミコロンで終わる1、別の式の一部ではない表現)の各値の計算と副作用は、各値の計算と副作用次のフル発現の効果の前に配列決定される.
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)
任意の演算子のオペランドの値の計算(ただし、副作用でなく)が演算子の結果の値の計算(ただし、その副作用)の前に順序付けされます.
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)
任意の引数の式に関連付けられたすべての値の計算と副作用、(関数がインライン展開され、明示的か否かの関数呼び出しの構文が使用されているかどうかに関係なく)関数を呼び出す、または呼び出された関数を指定置式と、前に配列決定されたとき呼び出された関数の本体内のすべての式またはステートメントの実行.
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)
内蔵のポストインクリメントとpostdecrement演算子の値の計算は、その副作用の前に配列決定される.
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)
組み込みの前置インクリメントとpredecrement演算子の副作用は、その値の計算(複合代入として定義による暗黙のルール)の前に配列決定される
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)
の最初の(左)の引数のすべての値の計算と副作用の組み込み論理AND演算子&&とビルトイン論理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)
論理で最初の式に関連付けられたすべての値の計算と副作用:?演算子は、第二または第三の式に関連付けられたすべての値の計算と副作用の前に配列決定される.
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)
組み込みの代入演算子のとの副作用は(左の引数の変更)複合代入演算子、組み込みのすべては、左と右の両方の引数の値の計算(ただし、副作用)の後に配列決定されており、前に配列決定される代入式の値の計算(変更されたオブジェクトへの参照を返す前に、つまり)
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)
すべての値の計算とビルトインコンマ演算子の最初(左)の引数の副作用はすべての値の計算と第二(右)引数の副作用の前に配列決定される.
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)
リスト初期化では、与えられた初期化句のすべての値の計算と副作用は初期化子リストのコンマ区切りのリストでそれを次のいずれかの初期化子の句に関連付けられたすべての値の計算と副作用の前に配列決定される.
Original:
In リスト初期化, 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)
別の関数呼び出しが不定に配列決定された後に(プログラムがas ifを振舞わなければならない別の関数呼び出しを構成するCPU命令は、関数がインライン化された場合でも、インターリーブされていなかった)の前に配列決定または配列決定されていない関数呼び出し
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)
割り当て関数(new演算子)への呼び出しは不定new式でコンストラクタの引数の評価に関して配列決定される
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.

[編集] 未定義の動作

1)
スカラオブジェクトに副作用が同じスカラオブジェクトの別の副作用に対する相対非配列されている場合、動作は未定義です.
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)
スカラオブジェクトに副作用が同じスカラオブジェクトの値を使用して、値の計算に相対非配列されている場合、動作は未定義です.
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

[編集] シーケンスポイントrulesNJ

[編集] 定義

式の評価は副作用を生じる可能性があります:ライブラリのI / O関数を呼び出すこと、またはこれらのいずれかの操作を行う関数を呼び出し、オブジェクトを変更すると、揮発性左辺値によって指定されたオブジェクトへのアクセス.
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.
シーケンスポイントはシーケンスの前の評価からのすべての副作用が完了している実行シーケンス内の点であり、その後の評価の副作用は開始されません.
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)
各フル式(通常は、セミコロンで)の末尾のシーケンスポイントがあります
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)
(関数がインライン展開されているか否かの関数呼び出し構文が使用されたかどうか)関数を呼び出すときは、内の任意の式や文の実行前に行われるすべての関数の引数の評価の後にシーケンスポイントは(もしあれば)がある関数本体
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)
関数の戻り値のコピーを行った後と関数外の任意の式の実行前にシーケンスポイントがあります.
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)
関数の実行が開始されると呼び出された関数の実行が(機能がインターリーブすることはできません)が完了するまで、呼び出し元の関数からの式は評価されません
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)
ビルトイン(非オーバーロード)の演算子を使用して、次の4つの各式の評価では、式の評価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

[編集] 未定義の動作

1)
前と次のシーケンスポイント間のスカラーオブジェクトは、式の評価では最大で1回修正され、その格納された値を持たなければならない.
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)
前と次のシーケンスポイント、式の評価によって修正されたスカラオブジェクトの前の値との間でのみ、格納される値を決定するためにアクセスされなければならない.
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

[編集] も参照してください

  • 演算子の優先順位式は、そのソース·コード表現から構築される方法を定義している.
    Original:
    演算子の優先順位 which defines how expressions are built from their source code representation.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • Cプログラミング言語の評価の順序.
    Original:
    評価の順序 in the C programming language.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.