23
Containers library
[containers]
23.6
Container adaptors
[container.adaptors]
23.6.3
Class template
queue
[queue]
23.6.3.1
Definition
[queue.defn]
1
#
Any sequence container supporting operations
front
(
)
,
back
(
)
,
push_
back
(
)
and
pop_
front
(
)
can be used to instantiate
queue
.
In particular,
list
and
deque
can be used
.
namespace
std
{
template
<
class
T,
class
Container
=
deque
<
T
>
>
class
queue
{
public
:
using
value_type
=
typename
Container
::
value_type;
using
reference
=
typename
Container
::
reference;
using
const_reference
=
typename
Container
::
const_reference;
using
size_type
=
typename
Container
::
size_type;
using
container_type
=
Container;
protected
:
Container c;
public
:
queue
(
)
:
queue
(
Container
(
)
)
{
}
explicit
queue
(
const
Container
&
)
;
explicit
queue
(
Container
&
&
)
;
template
<
class
InputIterator
>
queue
(
InputIterator first, InputIterator last
)
;
template
<
container-compatible-range
<
T
>
R
>
queue
(
from_range_t, R
&
&
rg
)
;
template
<
class
Alloc
>
explicit
queue
(
const
Alloc
&
)
;
template
<
class
Alloc
>
queue
(
const
Container
&
,
const
Alloc
&
)
;
template
<
class
Alloc
>
queue
(
Container
&
&
,
const
Alloc
&
)
;
template
<
class
Alloc
>
queue
(
const
queue
&
,
const
Alloc
&
)
;
template
<
class
Alloc
>
queue
(
queue
&
&
,
const
Alloc
&
)
;
template
<
class
InputIterator,
class
Alloc
>
queue
(
InputIterator first, InputIterator last,
const
Alloc
&
)
;
template
<
container-compatible-range
<
T
>
R,
class
Alloc
>
queue
(
from_range_t, R
&
&
rg,
const
Alloc
&
)
;
bool
empty
(
)
const
{
return
c
.
empty
(
)
;
}
size_type size
(
)
const
{
return
c
.
size
(
)
;
}
reference front
(
)
{
return
c
.
front
(
)
;
}
const_reference front
(
)
const
{
return
c
.
front
(
)
;
}
reference back
(
)
{
return
c
.
back
(
)
;
}
const_reference back
(
)
const
{
return
c
.
back
(
)
;
}
void
push
(
const
value_type
&
x
)
{
c
.
push_back
(
x
)
;
}
void
push
(
value_type
&
&
x
)
{
c
.
push_back
(
std
::
move
(
x
)
)
;
}
template
<
container-compatible-range
<
T
>
R
>
void
push_range
(
R
&
&
rg
)
;
template
<
class
.
.
.
Args
>
decltype
(
auto
)
emplace
(
Args
&
&
.
.
.
args
)
{
return
c
.
emplace_back
(
std
::
forward
<
Args
>
(
args
)
.
.
.
)
;
}
void
pop
(
)
{
c
.
pop_front
(
)
;
}
void
swap
(
queue
&
q
)
noexcept
(
is_nothrow_swappable_v
<
Container
>
)
{
using
std
::
swap; swap
(
c, q
.
c
)
;
}
}
;
template
<
class
Container
>
queue
(
Container
)
-
>
queue
<
typename
Container
::
value_type, Container
>
;
template
<
class
InputIterator
>
queue
(
InputIterator, InputIterator
)
-
>
queue
<
iter-value-type
<
InputIterator
>
>
;
template
<
ranges
::
input_
range
R
>
queue
(
from_range_t, R
&
&
)
-
>
queue
<
ranges
::
range_value_t
<
R
>
>
;
template
<
class
Container,
class
Allocator
>
queue
(
Container, Allocator
)
-
>
queue
<
typename
Container
::
value_type, Container
>
;
template
<
class
InputIterator,
class
Allocator
>
queue
(
InputIterator, InputIterator, Allocator
)
-
>
queue
<
iter-value-type
<
InputIterator
>
, deque
<
iter-value-type
<
InputIterator
>
, Allocator
>
>
;
template
<
ranges
::
input_
range
R,
class
Allocator
>
queue
(
from_range_t, R
&
&
, Allocator
)
-
>
queue
<
ranges
::
range_value_t
<
R
>
, deque
<
ranges
::
range_value_t
<
R
>
, Allocator
>
>
;
template
<
class
T,
class
Container,
class
Alloc
>
struct
uses_allocator
<
queue
<
T, Container
>
, Alloc
>
:
uses_allocator
<
Container, Alloc
>
::
type
{
}
;
}