operator>= (<utility>)
測試,如果左側的物件大於或等於右邊的物件。
template<Class Type>
bool operator>=(
const Type& _Left,
const Type& _Right
);
template<class Type1, class Type2>
bool operator>=(
const pair<Type1, Type2>& _Left,
const pair<Type1, Type2>& _Right
);
參數
_Left
型別 pair 物件在運算子的左側。_Right
型別 pair 物件在運算子的右邊。
傳回值
true ,如果左側的 pair 大於或等於 pair 在運算子的右邊,否則 false。
備註
在比較,這兩組值的第一個項目具有最高優先權。如果兩者不同,因為與的比較,則其比較的結果中取得。如果第一個項目的值不是不同的,則第二個項目的值相比對的比較,,而其比較的結果中取得。
範例
// utility_op_ge.cpp
// compile with: /EHsc
#include <utility>
#include <iomanip>
#include <iostream>
int main( )
{
using namespace std;
pair <int, double> p1, p2, p3, p4;
p1 = make_pair ( 10, 2.22e-1 );
p2 = make_pair ( 100, 1.11e-1 );
p3 = make_pair ( 10, 1.11e-1 );
p4 = make_pair ( 10, 2.22e-1 );
cout.precision ( 3 );
cout << "The pair p1 is: ( " << p1.first << ", "
<< p1.second << " )." << endl;
cout << "The pair p2 is: ( " << p2.first << ", "
<< p2.second << " )." << endl;
cout << "The pair p3 is: ( " << p3.first << ", "
<< p3.second << " )." << endl;
cout << "The pair p4 is: ( " << p4.first << ", "
<< p4.second << " )." << endl << endl;
if ( p1 >= p2 )
cout << "Pair p1 is greater than or equal to pair p2." << endl;
else
cout << "The pair p1 is less than the pair p2." << endl;
if ( p1 >= p3 )
cout << "Pair p1 is greater than or equal to pair p3." << endl;
else
cout << "The pair p1 is less than the pair p3." << endl;
if ( p1 >= p4 )
cout << "Pair p1 is greater than or equal to pair p4." << endl;
else
cout << "The pair p1 is less than the pair p4." << endl;
}
需求
標題: <utility>
命名空間: std