Aracılığıyla paylaş


operator< (<utility>)

İşlecinin sol tarafındaki çifti nesnesinin sınamaları sağ tarafındaki çifti nesnesi daha az olur.

template<class Type1, class Type2>
   bool operator<(
      const pair<Type1, Type2>& _Left,
      const pair<Type1, Type2>& _Right
   );

Parametreler

  • _Left
    Bir nesne türü pair işlecinin sol tarafındaki.

  • _Right
    Bir nesne türü pair işlecinin sağ tarafındaki.

Dönüş Değeri

gerçek , pair kesinlikle işleci sol tarafında ise'den küçük pair ; işlecinin sağ tarafındaki Aksi halde yanlış.

Notlar

_Leftpair Nesne kesinlikle olmasını söyledi'den küçük _Rightpair , nesne _Left küçük ve eşit değil_Right.

Çiftler bir Karşılaştırmada değerlerin ilk iki çiftleri öğelerinin en yüksek önceliğe sahip.Dosyalar farklıysa, kendi karşılaştırma sonucu çiftinin karşılaştırma sonucu olarak kabul edilir.İlk öğelerinin değerleri farklı olmaması durumunda, ikinci öğelerinin değerleri karşılaştırılır ve bunların karşılaştırma sonucu çiftinin karşılaştırma sonucu olarak alınır.

Örnek

// utility_op_lt.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, 2.22e-1 );
   p2 = make_pair ( 100, 1.11e-1 );
   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 pair p1 is less than the pair p2." << endl;
   else
      cout << "The pair p1 is not less than the pair p2." << endl;

   if ( p1 < p3 )
      cout << "The pair p1 is less than the pair p3." << endl;
   else
      cout << "The pair p1 is not less than the pair p3." << endl;
}
  
  
  
  
  

Gereksinimler

Başlık: <utility>

Namespace: std