共用方式為


set::value_comp

擷取集合中使用的 Command 項目值比較物件的複本。

value_compare value_comp( ) const;

傳回值

傳回集合使用排序其項目,是樣板參數 Traits的函式物件。

如需 Traits 的詳細資訊,請參閱 set Class 主題。

備註

在屬性中定義的成員函式:

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

要傳回 true ,如果 _xVal 前面並與 _yVal 不相等的排序順序。

請注意 value_comparekey_compare 是樣板參數的 Traits同義資料表。 這兩種類型的集合和多重集類別提供,則會針對對應和 multimap 類別的相容性相同,,它們是不同的。

範例

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

需求

標題: <set>

命名空間: std

請參閱

參考

set Class

set::key_comp 和 set::value_comp

標準樣板程式庫