Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
A type that provides a reference to a const element stored in a list for reading and performing const operations.
typedef typename Allocator::const_reference const_reference;
Remarks
A type const_reference cannot be used to modify the value of an element.
Example
// list_const_ref.cpp
// compile with: /EHsc
#include <list>
#include <iostream>
int main( )
{
using namespace std;
list <int> c1;
c1.push_back( 10 );
c1.push_back( 20 );
const list <int> c2 = c1;
const int &i = c2.front( );
const int &j = c2.back( );
cout << "The first element is " << i << endl;
cout << "The second element is " << j << endl;
// The following line would cause an error because c2 is const
// c2.push_back( 30 );
}
The first element is 10 The second element is 20
Requirements
Header: <list>
Namespace: std