public member function
<queue>
std::queue::queueexplicit queue (const container_type& ctnr = container_type());initialize (1)
explicit queue (const container_type& ctnr);move-initialize (2)
explicit queue (container_type&& ctnr = container_type());allocator (3)
template <class Alloc> explicit queue (const Alloc& alloc);init + allocator (4)
template <class Alloc> queue (const container_type& ctnr, const Alloc& alloc);move-init + allocator (5)
template <class Alloc> queue (container_type&& ctnr, const Alloc& alloc);copy + allocator (6)
template <class Alloc> queue (const queue& x, const Alloc& alloc);move + allocator (7)
template <class Alloc> queue (queue&& x, const Alloc& alloc);
Construct queue
Constructs a queue container adaptor object.A container adaptor keeps internally a container object as data. This container object is a copy of the ctnr argument passed to the constructor, if any, otherwise it is an empty container.
A container adaptor keeps internally a container object as data, which is initialized by this constructor:
std::move(cntr)
and alloc as arguments.
true
(for other types, the constructor does not even participate in overload resolution).
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// constructing queues
#include <iostream> // std::cout
#include <deque> // std::deque
#include <list> // std::list
#include <queue> // std::queue
int main ()
{
std::deque<int> mydeck (3,100); // deque with 3 elements
std::list<int> mylist (2,200); // list with 2 elements
std::queue<int> first; // empty queue
std::queue<int> second (mydeck); // queue initialized to copy of deque
std::queue<int,std::list<int> > third; // empty queue with list as underlying container
std::queue<int,std::list<int> > fourth (mylist);
std::cout << "size of first: " << first.size() << '\n';
std::cout << "size of second: " << second.size() << '\n';
std::cout << "size of third: " << third.size() << '\n';
std::cout << "size of fourth: " << fourth.size() << '\n';
return 0;
}
Output:
size of first: 0 size of second: 3 size of third: 0 size of fourth: 2
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