set::value_comp
Recupera una copia dell'oggetto di confronto utilizzato per ottenere i valori degli elementi di ordinamento in un gruppo.
value_compare value_comp( ) const;
Valore restituito
Restituisce l'oggetto function che un set utilizza per ordinare gli elementi, ovvero il parametro di template Traits.
Per ulteriori informazioni su Traits, vedere l'argomento Classe set.
Note
L'oggetto archiviato definisce la funzione membro:
bool operator(const Key& _xVal, const Key& _yVal);
quale restituisce true se _xVal precede e non è uguale a _yVal nell'ordinamento.
Si noti che sia value_compare che key_compare sono sinonimi per il parametro di template Tratti. Entrambi i tipi sono forniti per le classi di multi-insieme e set, in cui sono identici, per compatibilità con le classi di multimap e la mappa, in cui sono diversi.
Esempio
// 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;
}
}
Requisiti
Intestazione: <set>
Spazio dei nomi: std