次の方法で共有


multiset::value_comp

多重セットで使用される順序の要素の値の比較のオブジェクトのコピーを取得します。

value_compare value_comp( ) const;

戻り値

要素の順序を指定するには、テンプレート パラメーター Compareに多重セットが使用する関数オブジェクトを返します。

Compareの詳細については、multiset Class のトピックの " 解説 " を参照してください。

解説

格納されているオブジェクトには、メンバー関数を定義します:

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

_xVal の並べ替え順序の _yVal と一致させる前および true を返すかが。

key_comparevalue_compare の両方が Compareテンプレート パラメーターのシノニムであることに注意してください。どちらの型も設定、明確なクラス マップと multimap との互換性のために、同一であるクラスと多重セットに提供されます。

使用例

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

標準テンプレート ライブラリ