list::push_front
Öğe listesinin başına ekler.
void push_front(
const Type& _Val
);
void push_front(
Type&& _Val
);
Parametreler
Parametre |
Description |
_Val |
Öğe listesi başlangıcına eklenir. |
Notlar
Bir özel durum oluşursa, listenin sol değiştirmeden ve özel durum rethrown.
Örnek
// list_push_front.cpp
// compile with: /EHsc
#include <list>
#include <iostream>
#include <string>
int main( )
{
using namespace std;
list <int> c1;
c1.push_front( 1 );
if ( c1.size( ) != 0 )
cout << "First element: " << c1.front( ) << endl;
c1.push_front( 2 );
if ( c1.size( ) != 0 )
cout << "New first element: " << c1.front( ) << endl;
// move initialize a list of strings
list <string> c2;
string str("a");
c2.push_front( move( str ) );
cout << "Moved first element: " << c2.front( ) << endl;
}
Gereksinimler
Başlık: <list>
Namespace: std