次の方法で共有


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 ; ペアが等しい場合 false

解説

1 組は、それぞれの要素のそれぞれが等しい別のペアと同じです。2 セットは、1 回目または 2 番目の要素が他のペアの対応する要素と等しく等しくありません。

使用例

// utility_op_ne.cpp
// compile with: /EHsc
#include <utility>
#include <iomanip>
#include <iostream>

int main( )
{
   using namespace std;
   pair <int, double> p1, p2, p3;

   p1 = make_pair ( 10, 1.11e-1 );
   p2 = make_pair ( 1000, 1.11e-3 );
   p3 = make_pair ( 10, 1.11e-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 << endl;

   if ( p1 != p2 )
      cout << "The pairs p1 and p2 are not equal." << endl;
   else
      cout << "The pairs p1 and p2 are equal." << endl;

   if ( p1 != p3 )
      cout << "The pairs p1 and p3 are not equal." << endl;
   else
      cout << "The pairs p1 and p3 are equal." << endl;
}
  
  
  
  
  

必要条件

ヘッダー : <utility>

名前空間: std