名前空間
変種
操作

C++ Operator Precedence

提供: 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:
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.
優先順位 演算子 説明 結合性
1 :: スコープ解決 左から右
2 ++   -- 後置インクリメント・デクリメント
() 関数呼び出し
[] 配列添字
. 参照による要素選択
−> ポインタの要素選択
3 ++   -- 前置インクリメント・デクリメント 右から左
+   正・負の単項演算
!   ~ 論理 NOT およびビット単位 NOT
(type) 型キャスト
* 間接参照 (参照外し)
& アドレス
sizeof サイズ
new, new[] 動的メモリの確保
delete, delete[] 動的メモリの解放
4 .*   ->* メンバーへのポインタ 左から右
5 *   /   % 乗法,除法,剰余
6 +   加法,減法
7 <<   >> ビット単位左シフトと右シフト
8 <   <= 関係演算子 < および ≤
>   >= 関係演算子 > および ≥
9 ==   != 関係演算子 = および ≠
10 & ビット単位 AND
11 ^ ビット単位 XOR (排他的論理和)
12 | ビット単位 OR (包含的論理和)
13 && 論理 AND
14 || 論理 OR
15 ?: 三項条件 右から左
= 直接代入 (C++ class はデフォルトで提供)
+=   −= 和・差の累算代入
*=   /=   %= 積・商・剰余の累算代入
<<=   >>= ビット単位左シフト・右シフトの累算代入
&=   ^=   |= ビット単位 AND・XOR・OR の累算代入
16 throw throw 演算子 (例外)
17 , コンマ 左から右
式を解析する際には、いくつかの行に記載されている演算子は、その下にさらに行に上場されている任意の演算子よりも、その引数に(括弧であるかのように)緊密にバインドされます。
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.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
たとえば、式 std::cout<<a&b*p++ はそれぞれ (std::cout<<a)&b*(p++) として解析され、 std::cout<<(a&b)(*p)++ とはなりません。
(セルに記載されている演算子のいくつかの行があるかもしれません)、同じセル内にある演算子は、指定された方向に、同じ優先順位で評価されます。
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.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
例えば、式 a=b=c は右から左の結合性のため (a=b)=c ではなく a=(b=c) と解析されます。

演算子の優先順位は、オーバーロードによる影響を受けません。

[編集] ノート

規格自体は優先レベルを指定していません。彼らは文法から派生してい.
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.
const_caststatic_castdynamic_castreinterpret_casttypeid彼らは曖昧なことは決してありませんので、含まれていません.
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.

いくつかの演算子は代替スペルを持っています(例えば、and&&or||not!など)。

[編集] 参照

実行時に演算子の引数の評価の順序.
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.
Common operators
代入 incrementNJdecrement 算術 論理 比較 memberNJaccess 他の

a = b
a = rvalue
a += b
a -= b
a *= b
a /= b
a %= b
a &= b
a |= b
a ^= b
a <<= b
a >>= b

++a
--a
a++
a--

+a
-a
a + b
a - b
a * b
a / b
a % b
~a
a & b
a | b
a ^ b
a << b
a >> b

!a
a && b
a || b

a == b
a != b
a < b
a > b
a <= b
a >= b

a[b]
*a
&a
a->b
a.b
a->*b
a.*b

a(...)
a, b
(type) 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:
const_cast converts type to compatible type with different cv qualifiers
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:
sizeof... queries the size of a パラメーターパック (C++11およびそれ以降)
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:
noexcept checks if an expression can throw an exception (C++11およびそれ以降)
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.