次の方法で共有


hash_set::const_reference

[!メモ]

この API は、互換性のために残されています。代わりに unordered_set クラスです。

[const] の要素への参照を提供する型は [const] 操作を読み取りと操作実行のために格納されているhash_set

typedef list<typename Traits::value_type, typename Traits::allocator_type>::const_reference const_reference;

解説

Visual C++ .NET 2003では、<hash_map><hash_set> ヘッダー ファイルのメンバーはstdの名前空間に存在しなくなりましたが、ではなくstdextの名前空間に型。詳細については、「The stdext Namespace」を参照してください。

使用例

// hash_set_const_ref.cpp
// compile with: /EHsc
#include <hash_set>
#include <iostream>

int main( )
{
   using namespace std;
   using namespace stdext;
   hash_set <int> hs1;

   hs1.insert( 10 );
   hs1.insert( 20 );

   // Declare and initialize a const_reference &Ref1 
   // to the 1st element
   const int &Ref1 = *hs1.begin( );

   cout << "The first element in the hash_set is "
        << Ref1 << "." << endl;

   // The following line would cause an error because the 
   // const_reference cannot be used to modify the hash_set
   // Ref1 = Ref1 + 5;
}
  

必要条件

ヘッダー: <hash_set>

名前空間: のstdext

参照

関連項目

hash_set Class

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