multiset::value_comp

检索在多个集使用于顺序元素值比较对象的副本。

value_compare value_comp( ) const;

返回值

返回多个集使用对其元素,是模板参数 Compare的函数对象。

有关 Compare的更多信息,请参见 multiset Class 主题的"备注"节。

备注

存储的对象定义成员函数:

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

后者返回true;否则 _xVal 之前和与 _yVal 不相等按排序顺序。

请注意 key_comparevalue_compare 是模板参数的 Compare同义词。两个类型为设置的选件类提供,并且多级集,两者相同,与选件类兼容的映射和基于,其中它们是不同的。

示例

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

要求

标头: <set>

命名空间: std

请参见

参考

multiset Class

标准模板库