public member function
<deque>
std::deque::push_frontvoid push_front (const value_type& val);
void push_front (const value_type& val);void push_front (value_type&& val);
Insert element at beginning
Inserts a new element at the beginning of the deque container, right before its current first element. The content of val is copied (or moved) to the inserted element.This effectively increases the container size by one.
The storage for the new elements is allocated using the container's allocator, which may throw exceptions on failure (for the default allocator, bad_alloc is thrown if the allocation request does not succeed).
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// deque::push_front
#include <iostream>
#include <deque>
int main ()
{
std::deque<int> mydeque (2,100); // two ints with a value of 100
mydeque.push_front (200);
mydeque.push_front (300);
std::cout << "mydeque contains:";
for (std::deque<int>::iterator it = mydeque.begin(); it != mydeque.end(); ++it)
std::cout << ' ' << *it;
std::cout << '\n';
return 0;
}
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4