Udostępnij za pośrednictwem


set::value_comp

Pobiera kopię obiektu porównania używany do wartości kolejność elementów w zestawie.

value_compare value_comp( ) const;

Wartość zwracana

Zwraca obiekt funkcji używany przez zestaw do zamówienia jego elementów, który jest parametr szablonu Traits.

Aby uzyskać więcej informacji dotyczących Traits, zobacz temat set — Klasa.

Uwagi

Obiektu przechowywana definiuje funkcję członka:

bool operator(const Key& _xVal, const Key& _yVal);

która oblicza true Jeśli _xVal poprzedza i nie jest równa _yVal w kolejności sortowania.

Należy zauważyć, że zarówno value_compare i key_compare są synonimami dla parametru szablonu cechy.Oba typy są przewidziane zestaw i zestaw wielokrotny klas, gdzie są one identyczne, dla zachowania zgodności z mapy i klasy multimap, jeżeli są one różne.

Przykład

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

int main( )
{
   using namespace std;
   
   set <int, less<int> > s1;
   set <int, less<int> >::value_compare vc1 = s1.value_comp( );
   bool result1 = vc1( 2, 3 );
   if( result1 == true )   
   {
      cout << "vc1( 2,3 ) returns value of true, "
           << "where vc1 is the function object of s1."
           << endl;
   }
   else   
   {
      cout << "vc1( 2,3 ) returns value of false, "
           << "where vc1 is the function object of s1."
           << endl;
   }

   set <int, greater<int> > s2;
   set<int, greater<int> >::value_compare vc2 = s2.value_comp( );
   bool result2 = vc2( 2, 3 );
   if( result2 == true )   
   {
      cout << "vc2( 2,3 ) returns value of true, "
           << "where vc2 is the function object of s2."
           << endl;
   }
   else   
   {
      cout << "vc2( 2,3 ) returns value of false, "
           << "where vc2 is the function object of s2."
           << endl;
   }
}
  

Wymagania

Nagłówek: <set>

Przestrzeń nazw: std

Zobacz też

Informacje

set — Klasa

set::key_comp oraz set::value_comp

Standardowa biblioteka szablonów