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