std::queue<T,Container>::queue (3) - Linux Manuals
std::queue<T,Container>::queue: std::queue<T,Container>::queue
NAME
std::queue<T,Container>::queue - std::queue<T,Container>::queue
Synopsis
queue() : queue(Container()) { } (1) (since C++11)
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 > (6) (since C++11)
explicit queue( const Alloc& alloc );
template< class Alloc > (2) (7) (since C++11)
queue( const Container& cont, const Alloc& alloc );
template< class Alloc > (8) (since C++11)
queue( Container&& cont, const Alloc& alloc );
template< class Alloc > (9) (since C++11)
queue( const queue& other, const Alloc& alloc );
template< class Alloc > (10) (since C++11)
queue( queue&& other, const Alloc& alloc );
Constructs new underlying container of the container adaptor from a variety of data sources.
1) Default constructor. Value-initializes the container.
2) Copy-constructs the underlying container c with the contents of cont.
This is also the default constructor.
(until C++11)
3) Move-constructs the underlying container c with std::move(cont).
4) Copy constructor. The adaptor is copy-constructed with the contents of other.c. (implicitly declared)
5) Move constructor. The adaptor is constructed with std::move(other.c). (implicitly declared)
6-10) The following constructors are only defined if std::uses_allocator<container_type, Alloc>::value == true, that is, if the underlying container is an allocator-aware container (true for all standard library containers that can be used with queue).
6) Constructs the underlying container using alloc as allocator, as if by c(alloc).
7) Constructs the underlying container with the contents of cont and using alloc as allocator, as if by c(cont, alloc).
8) Constructs the underlying container with the contents of cont using move semantics while utilizing alloc as allocator, as if by c(std::move(cont), alloc).
9) Constructs the adaptor with the contents of other.c and using alloc as allocator, as if by c(other.c, alloc).
10) Constructs the adaptor with the contents of other using move semantics while utilizing alloc as allocator, as if by c(std::move(other.c), alloc).
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 (5-10) are only defined if Container meets the requirements of AllocatorAwareContainer
-
InputIt must meet the requirements of LegacyInputIterator.
Complexity
Same as the corresponding operation on the wrapped container.
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
Example
// Run this code
Output:
See also
operator= (public member function)