다음을 통해 공유


operator< (set)

Tests if the set object on the left side of the operator is less than the set object on the right side.

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

매개 변수

  • _Left
    An object of type set.

  • _Right
    An object of type set.

반환 값

true if the set on the left side of the operator is strictly less than the set on the right side of the operator; otherwise false.

설명

The comparison between set objects is based on a pairwise comparison of their elements. The less-than relationship between two objects is based on a comparison of the first pair of unequal elements.

예제

// 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;
}
  

요구 사항

헤더: <설정>

네임스페이스: std

참고 항목

참조

표준 템플릿 라이브러리