std::queue<T,Container>::queue
| queue() : queue(Container()) { } |
(1) | (since C++11) |
| (2) | ||
| explicit queue( const Container& cont = Container() ); |
(until C++11) | |
| explicit queue( const Container& cont ); |
(since C++11) | |
| explicit queue( Container&& cont ); |
(3) | (since C++11) |
| queue( const queue& other ); |
(4) | |
| queue( queue&& other ); |
(5) | (since C++11) |
| template< class Alloc > explicit queue( const Alloc& alloc ); |
(6) | (since C++11) |
| template< class Alloc > queue( const Container& cont, const Alloc& alloc ); |
(7) | (since C++11) |
| template< class Alloc > queue( Container&& cont, const Alloc& alloc ); |
(8) | (since C++11) |
| template< class Alloc > queue( const queue& other, const Alloc& alloc ); |
(9) | (since C++11) |
| template< class Alloc > queue( queue&& other, const Alloc& alloc ); |
(10) | (since C++11) |
Constructs new underlying container of the container adaptor from a variety of data sources.
c with the contents of cont. This is also the default constructor. (until C++11)c with std::move(cont).queue).alloc as allocator, as if by c(alloc).cont and using alloc as allocator, as if by c(cont, alloc).cont using move semantics while utilizing alloc as allocator, as if by c(std::move(cont), alloc).other.c and using alloc as allocator, as if by c(other.c, alloc).other using move semantics while utilizing alloc as allocator, as if by c(std::move(other.c), alloc).Contents |
[edit] Parameters
| alloc | - | allocator to use for all memory allocations of the underlying container |
| other | - | another container adaptor to be used as source to initialize the underlying container |
| cont | - | container to be used as source to initialize the underlying container |
| first, last | - | range of elements to initialize with |
| Type requirements | ||
-Alloc must meet the requirements of Allocator.
| ||
-Container must meet the requirements of Container. The constructors (6-10) are only defined if Container meets the requirements of AllocatorAwareContainer
| ||
-InputIt must meet the requirements of LegacyInputIterator.
| ||
[edit] Complexity
Same as the corresponding operation on the wrapped container.
[edit] Defect reports
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
| DR | Applied to | Behavior as published | Correct behavior |
|---|---|---|---|
| P0935R0 | C++11 | default constructor was explicit | made implicit |
[edit] Example
#include <queue> #include <deque> #include <iostream> int main() { std::queue<int> c1; c1.push(5); std::cout << c1.size() << '\n'; std::queue<int> c2(c1); std::cout << c2.size() << '\n'; std::deque<int> deq {3, 1, 4, 1, 5}; std::queue<int> c3(deq); std::cout << c3.size() << '\n'; }
Output:
1 1 5
[edit] See also
| assigns values to the container adaptor (public member function) |

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.
