Compartilhar via


hash_multimap::reference

ObservaçãoObservação

este API é obsoleto.Uma alternativa é unordered_multimap Class.

Um tipo que fornecesse uma referência a um elemento armazenado em um hash_multimap.

typedef list<typename _Traits::value_type, typename _Traits::allocator_type>::reference reference;

Comentários

Em o Visual C++ .NET 2003, os membros dos arquivos de cabeçalho de <hash_map> e de <hash_set> não estão mais no namespace de STD, mas tenham sido portados em vez de stdext no namespace.Consulte O namespace de stdext para mais informações.

Exemplo

// hash_multimap_reference.cpp
// compile with: /EHsc
#include <hash_map>
#include <iostream>

int main( )
{
   using namespace std;
   using namespace stdext;
   hash_multimap <int, int> hm1;
   typedef pair <int, int> Int_Pair;

   hm1.insert ( Int_Pair ( 1, 10 ) );
   hm1.insert ( Int_Pair ( 2, 20 ) );

   // Declare and initialize a const_reference &Ref1 
   // to the key of the first element
   const int &Ref1 = ( hm1.begin( ) -> first );

   // The following line would cause an error as the 
   // non-const_reference cannot be used to access the key
   // int &Ref1 = ( hm1.begin( ) -> first );

   cout << "The key of first element in the hash_multimap is "
        << Ref1 << "." << endl;

   // Declare and initialize a reference &Ref2 
   // to the data value of the first element
   int &Ref2 = ( hm1.begin( ) -> second );

   cout << "The data value of first element in the hash_multimap is "
        << Ref2 << "." << endl;

   //The non-const_reference can be used to modify the 
   //data value of the first element
   Ref2 = Ref2 + 5;
   cout << "The modified data value of first element is "
        << Ref2 << "." << endl;
}
  
  
  

Requisitos

Cabeçalho: <hash_map>

stdext denamespace:

Consulte também

Referência

hash_multimap Class

Standard Template Library