operator== (<stack>)
演算子の左側のスタックのオブジェクトが右側のスタックのオブジェクトと等しいかどうかを調べます。
bool operator==(
const stack <Type, Container>& _Left,
const stack <Type, Container>& _Right
);
パラメーター
_Left
**[スタック]**型のオブジェクト。_Right
**[スタック]**型のオブジェクト。
戻り値
スタックまたはスタックが等しい場合true ; スタックまたはスタックがではない false。
解説
スタックのオブジェクトの比較は、要素のペアに比較に基づいています。2 個のスタックの要素の数が同じで、対応する要素の値が同じ同じです。それ以外の場合は等しくありません。
使用例
// stack_op_eq.cpp
// compile with: /EHsc
#include <stack>
#include <vector>
#include <iostream>
int main( )
{
using namespace std;
// Declares stacks with vector base containers
stack <int, vector<int> > s1, s2, s3;
// The following would have cause an error because stacks with
// different base containers are not equality comparable
// stack <int, list<int> > s3;
s1.push( 1 );
s2.push( 2 );
s3.push( 1 );
if ( s1 == s2 )
cout << "The stacks s1 and s2 are equal." << endl;
else
cout << "The stacks s1 and s2 are not equal." << endl;
if ( s1 == s3 )
cout << "The stacks s1 and s3 are equal." << endl;
else
cout << "The stacks s1 and s3 are not equal." << endl;
}
必要条件
ヘッダー: <stack>
名前空間: std