Freigeben über


map::key_comp

Ruft eine Kopie des Vergleichsobjekts ab, das den Reihenfolgentasten in einer Zuordnung verwendet wird.

key_compare key_comp( ) const;

Rückgabewert

Gibt dem Funktionsobjekt zurück, das eine Zuordnung verwendet, um ihre Elemente auf.

Hinweise

Das gespeicherte Objekt definiert die Memberfunktion

bool operator(const,Taste & _Leftconst Key & _Right);

welches true zurückgibt, wenn _Left nicht gleich _Right in der Sortierreihenfolge vor und ist.

Beispiel

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

Anforderungen

Header: <map>

Namespace: std

Siehe auch

Referenz

map-Klasse

Standardvorlagenbibliothek