共用方式為


hash_set::const_reference

注意事項注意事項

這個 API 已經過時。這個選項是 unordered_set Class

提供對 const 項目之參考的型別在讀取及執行 const 作業一 hash_set 儲存。

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

備註

在 Visual C++ .NET Pocket PC, <hash_map><hash_set> 標頭檔 (Header File) 的成員不在 std 命名空間,,而是移至 stdext 命名空間。 如需詳細資訊,請參閱 stdext 命名空間

範例

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

標準樣板程式庫