Freigeben über


deque::const_reference

Ein Typ, der einen Verweis auf ein const-Element enthält, in einer Doppelschlange zum Lesen und Ausführen von Operationen const.

typedef typename Allocator::const_reference const_reference;

Hinweise

Ein const_reference-Typ kann nicht zum Ändern des Werts eines Elements verwendet werden.

Beispiel

// deque_const_ref.cpp
// compile with: /EHsc
#include <deque>
#include <iostream>

int main( ) 
{
   using namespace std;
   deque <int> c1;
   
   c1.push_back( 10 );
   c1.push_back( 20 );

   const deque <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 as c2 is const
   // c2.push_back( 30 );
}
  

Anforderungen

Header: <deque>

Namespace: std

Siehe auch

Referenz

deque-Klasse

Standardvorlagenbibliothek