[ Web Proxy ]
URL:
Viewing: http://ru.cppreference.com/cpp/container/queue/queue [Back]  [Original]

std::queue::queue cppreference.com
cppreference.com

std::queue::queue

cppreference.com

<metanoindex/>

<tbody> </tbody>
explicit queue( const Container& cont = Container() ); explicit queue( const Container& cont );
(1) ( C++11)
( C++11)
explicit queue( Container&& cont = Container() );
(2) ( C++11)
queue( const queue& other );
(3)
queue( queue&& other );
(4) ( C++11)
template< class Alloc > explicit queue( const Alloc& alloc );
(5) ( C++11)
template< class Alloc > queue( const Container& cont, const Alloc& alloc );
(6) ( C++11)
template< class Alloc > queue( Container&& cont, const Alloc& alloc );
(7) ( C++11)
template< class Alloc > queue( const queue& other, const Alloc& alloc );
(8) ( C++11)
template< class Alloc > queue( queue&& other, const Alloc& alloc );
(9) ( C++11)
.
:
Constructs new underlying container of the container adaptor from a variety of data sources.
Google.
. .
1)
c cont. ( C++11)
:
Copy-constructs the underlying container c with the contents of cont. This is also the default constructor ( C++11)
Google.
. .
2)
Move- c std::move(cont). ( C++11)
:
Move-constructs the underlying container c with std::move(cont). This is also the default constructor ( C++11)
Google.
. .
3)
. other.c. ( )
:
Copy constructor. The adaptor is copy-constructed with the contents of other.c. ( )
Google.
. .
4)
. std::move(other.c). ( )
:
Move constructor. The adaptor is constructed with std::move(other.c). ( )
Google.
. .
5-9)
std::uses_allocator<container_type, Alloc>::value == true, , - ( ).
:
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).
Google.
. .
5)
alloc . c(alloc).
:
Constructs the underlying container using alloc as allocator. Effectively calls c(alloc).
Google.
. .
6)
cont alloc . c(cont, alloc).
:
Constructs the underlying container with the contents of cont and using alloc as allocator. Effectively calls c(cont, alloc).
Google.
. .
7)
cont alloc . c(std::move(cont), alloc).
:
Constructs the underlying container with the contents of cont using move semantics while utilising alloc as allocator. Effectively calls c(std::move(cont), alloc).
Google.
. .
8)
other.c alloc . c(athor.c, alloc).
:
Constructs the adaptor with the contents of other.c and using alloc as allocator. Effectively calls c(athor.c, alloc).
Google.
. .
9)
other alloc . c(std::move(other.c), alloc).
:
Constructs the adaptor with the contents of other using move semantics while utilising alloc as allocator. Effectively calls c(std::move(other.c), alloc).
Google.
. .

alloc
:
allocator to use for all memory allocations of the underlying container
Google.
. .
other
:
another container adaptor to be used as source to initialize the underlying container
Google.
. .
cont
:
container to be used as source to initialize the underlying container
Google.
. .
first, last
:
range of elements to initialize with
Google.
. .
-
Alloc Allocator.
-
Container Container. The constructors (5-10) are only defined if Container meets the requirements of AllocatorAwareContainer
-
InputIt InputIterator.

1, 3, 5, 6, 8: cont other
:
1, 3, 5, 6, 8: linear in cont or other
Google.
. .
2, 4, 7, 9:
:
2, 4, 7, 9: constant
Google.
. .

#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';
}

:

1
1
5

.


(public -) []

Web Proxy Viewer  |  New URL  |  Original Page