C++ Operator Precedence
提供: cppreference.com
![]() |
このページは、Google 翻訳を使って英語版から機械翻訳されました。
翻訳には誤りや奇妙な言い回しがあるかもしれません。文章の上にポインタをおくと、元の文章が見れます。誤りを修正して翻訳を改善する手助けをしてください。翻訳についての説明は、ここをクリックしてください。 |
次の表は、C + +演算子の優先順位と結合性を示しています。演算子は優先順位の降順で、上から下に記載されています.
Original:
The following table lists the precedence and associativity of C++ operators. Operators are listed top to bottom, in descending precedence.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Precedence | Operator | Description | Associativity |
---|---|---|---|
1 | ::
|
Scope resolution | Left-to-right |
2 | ++ --
|
Suffix/postfix increment and decrement | |
()
|
Function call | ||
[]
|
Array subscripting | ||
.
|
Element selection by reference | ||
−>
|
Element selection through pointer | ||
3 | ++ --
|
Prefix increment and decrement | Right-to-left |
+ −
|
Unary plus and minus | ||
! ~
|
Logical NOT and bitwise NOT | ||
(type)
|
Type cast | ||
*
|
Indirection (dereference) | ||
&
|
Address-of | ||
sizeof
|
Size-of | ||
new , new[]
|
Dynamic memory allocation | ||
delete , delete[]
|
Dynamic memory deallocation | ||
4 | .* ->*
|
Pointer to member | Left-to-right |
5 | * / %
|
Multiplication, division, and remainder | |
6 | + −
|
Addition and subtraction | |
7 | << >>
|
Bitwise left shift and right shift | |
8 | < <=
|
For relational operators < and ≤ respectively | |
> >=
|
For relational operators > and ≥ respectively | ||
9 | == !=
|
For relational = and ≠ respectively | |
10 | &
|
Bitwise AND | |
11 | ^
|
Bitwise XOR (exclusive or) | |
12 | |
|
Bitwise OR (inclusive or) | |
13 | &&
|
Logical AND | |
14 | ||
|
Logical OR | |
15 | ?:
|
Ternary conditional | Right-to-left |
=
|
Direct assignment (provided by default for C++ classes) | ||
+= −=
|
Assignment by sum and difference | ||
*= /= %=
|
Assignment by product, quotient, and remainder | ||
<<= >>=
|
Assignment by bitwise left shift and right shift | ||
&= ^= |=
|
Assignment by bitwise AND, XOR, and OR | ||
16 | throw
|
Throw operator (for exceptions) | |
17 | ,
|
Comma | Left-to-right |
式を解析する際には、いくつかの行に記載されている演算子は、その下にさらに行に上場されている任意の演算子よりも、その引数に(括弧であるかのように)緊密にバインドされます。たとえば、表現std::cout<<a&bと*p++(std::cout<<a)&bとして解析され、*(p++)はなく、std::cout<<(a&b)として、または(*p)++.
Original:
When parsing an expression, an operator which is listed on some row will be bound tighter (as if by parentheses) to its arguments than any operator that is listed on a row further below it. For example, the expressions std::cout<<a&b and *p++ are parsed as (std::cout<<a)&b and *(p++), and not as std::cout<<(a&b) or (*p)++.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
(セルに記載されている演算子のいくつかの行があるかもしれません)、同じセル内にある演算子は、指定された方向に、同じ優先順位で評価されます。例えば、発現a=b=cはa=(b=c)として解析されていないので右から左への結合性の(a=b)=cとされ.
Original:
Operators that are in the same cell (there may be several rows of operators listed in a cell) are evaluated with the same precedence, in the given direction. For example, the expression a=b=c is parsed as a=(b=c), and not as (a=b)=c because of right-to-left associativity.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
演算子の優先順位は、過負荷による影響を受けません.
Original:
An operator's precedence is unaffected by overloading.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[編集] ノート
規格自体は優先レベルを指定していません。彼らは文法から派生してい.
Original:
The standard itself doesn't specify precedence levels. They are derived from the grammar.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
const_cast、static_cast、dynamic_cast、reinterpret_castとtypeid彼らは曖昧なことは決してありませんので、含まれていません.
Original:
const_cast, static_cast, dynamic_cast, reinterpret_cast and typeid are not included since they are never ambiguous.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
演算子の中には代替スペルを持っている(例えば、and
&&
ため、or||
ため、not!
用など).Original:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[編集] 参照
実行時に演算子の引数の評価の順序.
Original:
評価の順序 of operator arguments 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.
You can help to correct and verify the translation. Click here for instructions.
Common operators | ||||||
---|---|---|---|---|---|---|
代入 | incrementNJdecrement | 算術 | 論理 | 比較 | memberNJaccess | 他の |
a = b |
++a |
+a |
!a |
a == b |
a[b] |
a(...) |
Special operators | ||||||
static_cast別の互換性のあるタイプ
に1型に変換します Original: static_cast converts one type to another compatible type The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. dynamic_cast派生class
に仮想基底クラスに変換します Original: dynamic_cast converts virtual base class to derived class The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. const_cast異なるcvqualifiers
と互換性のある型に型変換されます Original: The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. reinterpret_cast互換性type
に型を変換します Original: reinterpret_cast converts type to incompatible type The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. new割り当てmemory
Original: new allocates memory The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. delete割り当て解除memory
Original: delete deallocates memory The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. sizeoftype
のサイズを照会します Original: sizeof queries the size of a type The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. sizeof...パラメーターパック(C++11およびそれ以降)
のサイズを照会します Original: The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. typeidtype
の型情報を照会します Original: typeid queries the type information of a type 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: The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. alignofタイプ(C++11およびそれ以降)のクエリアラインメント要件を
Original: alignof queries alignment requirements of a type (C++11およびそれ以降) The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |