public member function
<deque>
std::deque::push_backvoid push_back (const value_type& val);
void push_back (const value_type& val);void push_back (value_type&& val);
Add element at the end
Adds a new element at the end of the deque container, after its current last element. The content of val is copied (or moved) to the new 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
18
19
20
// deque::push_back
#include <iostream>
#include <deque>
int main ()
{
std::deque<int> mydeque;
int myint;
std::cout << "Please enter some integers (enter 0 to end):\n";
do {
std::cin >> myint;
mydeque.push_back (myint);
} while (myint);
std::cout << "mydeque stores " << (int) mydeque.size() << " numbers.\n";
return 0;
}
The example uses push_back to add a new element to the container each time a new integer is read.
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