STD::QUEUE(3)

πŸ’– NAME πŸ’–

okay bestie, welcome to the Library Functions Manual, section 3 β€” this is where the C++ girlies live πŸ’…

std::queue< _Tp, _Sequence > β€” a standard container giving FIFO behavior. first in, first out, no cutting the line, periodt πŸŽ€


🌸 SYNOPSIS 🌸

#include <queue>

✨ Public Types ✨

  • typedef _Sequence::const_reference const_reference
  • typedef _Sequence container_type
  • typedef _Sequence::reference reference
  • typedef _Sequence::size_type size_type
  • typedef _Sequence::value_type value_type

✨ Public Member Functions ✨

template<typename _Seq = _Sequence, typename _Requires = typename enable_if<is_default_constructible<_Seq>::value>::type> queue ()

β€” Default constructor creates no elements.

queue (_Sequence &&__c)
template<typename _Alloc, typename _Requires = _Uses<_Alloc>> queue (_Sequence &&__c, const _Alloc &__a)
template<typename _Alloc, typename _Requires = _Uses<_Alloc>> queue (const _Alloc &__a)
queue (const _Sequence &__c)
template<typename _Alloc, typename _Requires = _Uses<_Alloc>> queue (const _Sequence &__c, const _Alloc &__a)
template<typename _Alloc, typename _Requires = _Uses<_Alloc>> queue (const queue &__q, const _Alloc &__a)
template<typename _Alloc, typename _Requires = _Uses<_Alloc>> queue (queue &&__q, const _Alloc &__a)
reference back ()
const_reference back () const
template<typename... _Args> decltype(auto) emplace (_Args &&... __args)
bool empty () const
reference front ()
const_reference front () const
void pop ()

β€” Removes first element.

void push (const value_type &__x)

β€” Add data to the end of the queue.

void push (value_type &&__x)
size_type size () const
void swap (queue &__q) noexcept(__is_nothrow_swappable< _Sequence >::value)

✨ Protected Attributes ✨

  • _Sequence c β€” c is the underlying container.

✨ Friends ✨

template<typename _Tp1, typename _Seq1> bool operator< (const queue< _Tp1, _Seq1 > &, const queue< _Tp1, _Seq1 > &)
template<typename _Tp1, three_way_comparable _Seq1> compare_three_way_result_t< _Seq1 > operator<=> (const queue< _Tp1, _Seq1 > &, const queue< _Tp1, _Seq1 > &)
template<typename _Tp1, typename _Seq1> bool operator== (const queue< _Tp1, _Seq1 > &, const queue< _Tp1, _Seq1 > &)

πŸ¦‹ Detailed Description πŸ¦‹

template<typename _Tp, typename _Sequence = deque<_Tp>>
class std::queue< _Tp, _Sequence >

A standard container giving FIFO behavior. ✨

πŸŽ€ Template Parameters πŸŽ€

  • _Tp β€” Type of element.
  • _Sequence β€” Type of underlying sequence, defaults to deque<_Tp>.

so here's the tea β˜• β€” this thing meets many of the requirements of a container, but it does not define anything to do with iterators. and like, very few of the other standard container interfaces are defined. she's minimal, she's mysterious, she's not gonna give you everything πŸ™ˆ

this is not a true container, bestie β€” it's an adaptor. it holds another container, and provides a wrapper interface to that container. the wrapper is what enforces strict first-in-first-out queue behavior. the drama? the wrapper. the rules? also the wrapper. πŸ’…

the second template parameter defines the type of the underlying sequence/container. it defaults to std::deque, but it can be any type that supports front, back, push_back, and pop_front, such as std::list or an appropriate user-defined type. so flexible, so chic 🌈

members not found in normal containers are container_type, which is a typedef for the second Sequence parameter, and push and pop, which are standard queue/FIFO operations. iconic behavior honestly πŸ‘‘


🌟 Constructor & Destructor Documentation 🌟

template<typename _Tp, typename _Sequence = deque<_Tp>> template<typename _Seq = _Sequence, typename _Requires = typename enable_if<is_default_constructible<_Seq>::value>::type> std::queue< _Tp, _Sequence >::queue () [inline]

Default constructor creates no elements. empty girl era, no cap 🫢

References c.


πŸ’œ Member Function Documentation πŸ’œ

template<typename _Tp, typename _Sequence = deque<_Tp>> reference std::queue< _Tp, _Sequence >::back () [inline], [nodiscard]

Returns a read/write reference to the data at the last element of the queue. so you can peek the back AND change it, main character energy πŸ’…

References c.


template<typename _Tp, typename _Sequence = deque<_Tp>> const_reference std::queue< _Tp, _Sequence >::back () const [inline], [nodiscard]

Returns a read-only (constant) reference to the data at the last element of the queue. look, don't touch πŸŽ€

References c.


template<typename _Tp, typename _Sequence = deque<_Tp>> bool std::queue< _Tp, _Sequence >::empty () const [inline], [nodiscard]

Returns true if the queue is empty. vibe check: is she empty? 😭

References c.


template<typename _Tp, typename _Sequence = deque<_Tp>> reference std::queue< _Tp, _Sequence >::front () [inline], [nodiscard]

Returns a read/write reference to the data at the first element of the queue. the girl at the front of the line, and yes you can edit her ✨

References c.


template<typename _Tp, typename _Sequence = deque<_Tp>> const_reference std::queue< _Tp, _Sequence >::front () const [inline], [nodiscard]

Returns a read-only (constant) reference to the data at the first element of the queue. read her, don't rewrite her πŸ™ˆ

References c.


template<typename _Tp, typename _Sequence = deque<_Tp>> void std::queue< _Tp, _Sequence >::pop () [inline]

Removes first element. this is a typical queue operation β€” it shrinks the queue by one. the time complexity of the operation depends on the underlying sequence. πŸ”₯

⚠️ note that no data is returned, and if the first element's data is needed, it should be retrieved before pop() is called. so grab front() first, bestie, or that data is GONE πŸ’€

References c.


template<typename _Tp, typename _Sequence = deque<_Tp>> void std::queue< _Tp, _Sequence >::push (const value_type & __x) [inline]

Add data to the end of the queue. get in line, girl πŸšΆβ€β™€οΈ

Parameters

  • __x β€” Data to be added.

this is a typical queue operation. the function creates an element at the end of the queue and assigns the given data to it. the time complexity of the operation depends on the underlying sequence. πŸ¦‹

References c.


template<typename _Tp, typename _Sequence = deque<_Tp>> size_type std::queue< _Tp, _Sequence >::size () const [inline], [nodiscard]

Returns the number of elements in the queue. how many girlies are in the line? πŸ’–

References c.


πŸ“ Member Data Documentation πŸ“

template<typename _Tp, typename _Sequence = deque<_Tp>> _Sequence std::queue< _Tp, _Sequence >::c [protected]

c is the underlying container. the real one behind the scenes, the one carrying the whole operation πŸ’…

Referenced by queue(), back(), back(), empty(), front(), front(), std::operator<(), std::operator==(), pop(), push(), and size().


πŸ‘‘ Author πŸ‘‘

Generated automatically by Doxygen for libstdc++ from the source code. no thoughts, just generated πŸ’–


and that's the whole page, bestie!! πŸŽ€ generated automatically by Doxygen for libstdc++ from the source code β€” libstdc++, std::queue...Sequence >(3), mwah, slay, go write some FIFO code πŸŒˆβœ¨πŸ¦‹

πŸ“¦ where this page comes from
  • arch rolling: gcc 16.2.1+r23+gd564253eb6c8-1 Β· GPL-3.0-or-later WITH GCC-exception-3.1 AND GFDL-1.3-or-later
  • fedora 44: libstdc++-docs 16.0.1-0.10.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
  • fedora 44: libstdc++-docs 16.2.1-2.fc44
  • fedora 44: libstdc++-docs 16.2.1-3.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms