다음을 통해 공유


map::key_comp

순서 키 맵에서 사용 되는 비교 개체의 복사본을 검색 합니다.

key_compare key_comp( ) const;

반환 값

지도 사용 하 여 요소를 정렬 하는 함수 개체를 반환 합니다.

설명

저장 된 개체 멤버 함수를 정의합니다.

bool operator(constKey&_Left, const Key&_Right);

반환 true 경우 _Left 앞에 같지 않은 경우 _Right 정렬 순서에서.

예제

// map_key_comp.cpp
// compile with: /EHsc
#include <map>
#include <iostream>

int main( )
{
   using namespace std;
   
   map <int, int, less<int> > m1;
   map <int, int, less<int> >::key_compare kc1 = m1.key_comp( ) ;
   bool result1 = kc1( 2, 3 ) ;
   if( result1 == true )
   {
      cout << "kc1( 2,3 ) returns value of true, "
           << "where kc1 is the function object of m1."
           << endl;
   }
   else   
   {
      cout << "kc1( 2,3 ) returns value of false "
           << "where kc1 is the function object of m1."
           << endl;
   }

   map <int, int, greater<int> > m2;
   map <int, int, greater<int> >::key_compare kc2 = m2.key_comp( );
   bool result2 = kc2( 2, 3 ) ;
   if( result2 == true )
   {
      cout << "kc2( 2,3 ) returns value of true, "
           << "where kc2 is the function object of m2."
           << endl;
   }
   else   
   {
      cout << "kc2( 2,3 ) returns value of false, "
           << "where kc2 is the function object of m2."
           << endl;
   }
}
  
  

요구 사항

헤더: <map>

네임 스페이스: std

참고 항목

참조

map Class

표준 템플릿 라이브러리