次の方法で共有


operator< (set)

演算子の左側のオブジェクト セットが右側の設定オブジェクトより小さいかどうかを調べます。

bool operator<( 
   const set <Key, Traits, Allocator>& _Left, 
   const set <Key, Traits, Allocator>& _Right 
);

パラメーター

  • _Left
    設定オブジェクト。

  • _Right
    設定オブジェクト。

戻り値

演算子の左側の設定は厳密には演算子の右側の設定よりも小さいtrue ; それ false

解説

設定オブジェクトの比較は要素の比較に一対に基づいています。 2 種類のオブジェクトの関係 (より小さい等しくない要素の最初のペアの比較に基づいて決定されます。

使用例

// set_op_lt.cpp
// compile with: /EHsc
#include <set>
#include <iostream>

int main( )
{
   using namespace std;
   set <int> s1, s2, s3;
   int i;

   for ( i = 0 ; i < 3 ; i++ )
   {
      s1.insert ( i );
      s2.insert ( i * i );
      s3.insert ( i - 1 );
   }

   if ( s1 < s2 )
      cout << "The set s1 is less than the set s2." << endl;
   else
      cout << "The set s1 is not less than the set s2." << endl;

   if ( s1 < s3 )
      cout << "The set s1 is less than the set s3." << endl;
   else
      cout << "The set s1 is not less than the set s3." << endl;
}
  

必要条件

ヘッダー: <set>

名前空間: std

参照

関連項目

標準テンプレート ライブラリ