hash_multimap::const_reference
A type that provides a reference to a const element stored in a hash_multimap for reading and performing const operations.
typedef list<typename _Traits::value_type, typename _Traits::allocator_type>::const_reference const_reference;
Remarks
In Visual C++ .NET 2003, members of the <hash_map> and <hash_set> header files are no longer in the std namespace, but rather have been moved into the stdext namespace. See The stdext Namespace for more information.
Example
// hash_multimap_const_ref.cpp
// compile with: /EHsc
#define _DEFINE_DEPRECATED_HASH_CLASSES 0
#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 because 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 1st element in the hash_multimap is "
<< Ref2 << "." << endl;
}
The key of first element in the hash_multimap is 1.
The data value of 1st element in the hash_multimap is 10.
Requirements
Header: <hash_map>
Namespace: stdext