public member function
<deque>
std::deque::deque default (1)explicit deque (const allocator_type& alloc = allocator_type());fill (2)
explicit deque (size_type n, const value_type& val = value_type(), const allocator_type& alloc = allocator_type());range (3)
template <class InputIterator> deque (InputIterator first, InputIterator last, const allocator_type& alloc = allocator_type());copy (4)
deque (const deque& x);default (1)
explicit deque (const allocator_type& alloc = allocator_type());fill (2)
explicit deque (size_type n); deque (size_type n, const value_type& val, const allocator_type& alloc = allocator_type());range (3)
template <class InputIterator> deque (InputIterator first, InputIterator last, const allocator_type& alloc = allocator_type());copy (4)
deque (const deque& x);deque (const deque& x, const allocator_type& alloc);move (5)
deque (deque&& x);deque (deque&& x, const allocator_type& alloc);initializer list (6)
deque (initializer_list<value_type> il, const allocator_type& alloc = allocator_type());default (1)
deque();explicit deque (const allocator_type& alloc);fill (2)
explicit deque (size_type n, const allocator_type& alloc = allocator_type()); deque (size_type n, const value_type& val, const allocator_type& alloc = allocator_type());range (3)
template <class InputIterator> deque (InputIterator first, InputIterator last, const allocator_type& alloc = allocator_type());copy (4)
deque (const deque& x);deque (const deque& x, const allocator_type& alloc);move (5)
deque (deque&& x);deque (deque&& x, const allocator_type& alloc);initializer list (6)
deque (initializer_list<value_type> il, const allocator_type& alloc = allocator_type());
Construct deque container
Constructs a deque container object, initializing its contents depending on the constructor version used:The container keeps an internal copy of
alloc, which is used to allocate storage throughout its lifetime. If no
allocargument is passed to the constructor, a default-constructed allocator is used, except in the following case:
- The copy constructor
(4)creates a container that keeps and uses a copy of
x's allocator.
The storage for the elements is allocated using this internal allocator.
The container keeps an internal copy of
alloc, which is used to allocate and deallocate storage for its elements, and to construct and destroy them (as specified by its
allocator_traits). If no
allocargument is passed to the constructor, a default-constructed allocator is used, except in the following cases:
- The copy constructor
(4, first signature)creates a container that keeps and uses a copy of the allocator returned by calling the appropriate
selected_on_container_copy_constructiontrait on
x's allocator.
- The move constructor
(5, first signature)acquires
x's allocator.
All elements are copied, moved or otherwise constructed by calling allocator_traits::construct with the appropriate arguments.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// constructing deques
#include <iostream>
#include <deque>
int main ()
{
unsigned int i;
// constructors used in the same order as described above:
std::deque<int> first; // empty deque of ints
std::deque<int> second (4,100); // four ints with value 100
std::deque<int> third (second.begin(),second.end()); // iterating through second
std::deque<int> fourth (third); // a copy of third
// the iterator constructor can be used to copy arrays:
int myints[] = {16,2,77,29};
std::deque<int> fifth (myints, myints + sizeof(myints) / sizeof(int) );
std::cout << "The contents of fifth are:";
for (std::deque<int>::iterator it = fifth.begin(); it!=fifth.end(); ++it)
std::cout << ' ' << *it;
std::cout << '\n';
return 0;
}
Output:
The contents of fifth are: 16 2 77 29
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