multiset::value_comp

Recupera una copia dell'oggetto di confronto utilizzato per i valori degli elementi di ordinamento in un multi-insieme.

value_compare value_comp( ) const;

Valore restituito

Restituisce l'oggetto funzione che un multi-insieme utilizza per ordinare gli elementi, che è il parametro di template Compare.

Per ulteriori informazioni su Compare, vedere la sezione relativa alle osservazioni dell'argomento multiset Class.

Note

L'oggetto memorizzato definisce la funzione membro:

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

quali restituisce true se _xVal precede e non è uguale a _yVal ordinati.

Si noti che sia key_compare che value_compare sono sinonimi per il parametro di template Compare.Entrambi i tipi sono forniti per le classi e impostare il multi-insieme, dove sono identici, per la compatibilità con il mapping e il multimap di classi, in cui sono diversi.

Esempio

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

int main( )
{
   using namespace std;
   
   multiset <int, less<int> > ms1;
   multiset <int, less<int> >::value_compare vc1 = ms1.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 ms1."
           << endl;
   }
   else   
   {
      cout << "vc1( 2,3 ) returns value of false, "
           << "where vc1 is the function object of ms1."
           << endl;
   }

   set <int, greater<int> > ms2;
   set<int, greater<int> >::value_compare vc2 = ms2.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 ms2."
           << endl;
   }
   else   
   {
      cout << "vc2( 2,3 ) returns value of false, "
           << "where vc2 is the function object of ms2."
           << endl;
   }
}
  
  

Requisiti

intestazione: <set>

Spazio dei nomi: deviazione standard

Vedere anche

Riferimenti

multiset Class

Libreria di modelli standard