STD::QUEUE(3cxx)
π¦ std::queue< _Tp, _Sequence > β NAME π
okay so bestie, welcome to the 3cxx manual page for std::queue< _Tp, _Sequence > β and honestly? It's giving βstandard container giving FIFO behavior.β That's the whole NAME vibe: a standard container that does first-in-first-out, no cap. π
β¨ SYNOPSIS β¨
#include <queue>
πΈ Public Types πΈ
typedef _Sequence::const_reference const_referencetypedef _Sequence container_typetypedef _Sequence::reference referencetypedef _Sequence::size_type size_typetypedef _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 () consttemplate<typename... _Args> decltype(auto) emplace (_Args &&... __args)bool empty () constreference front ()const_reference front () constvoid 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 () constvoid 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 todeque<_Tp>.
Okay 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. Very few of the other standard container interfaces are defined. It's lowkey not a βtrue containerβ at all β it's an adaptor. It holds another container and gives you a wrapper interface to that container. The wrapper is literally what enforces strict first-in-first-out queue behavior. β¨
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. Iconic flexibility, honestly.
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. Periodt. π«Ά
π Constructor & Destructor Documentation π
π queue () β default constructor
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 queue, clean slate, main character energy. π
π₯ Member Function Documentation π₯
back()
template<typename _Tp , typename _Sequence = deque<_Tp>> reference
std::queue< _Tp, _Sequence >::back () [inline]
Returns a read/write reference to the data at the last element of the queue.
References std::queue< _Tp, _Sequence >::c.
back() const
template<typename _Tp , typename _Sequence = deque<_Tp>> const_reference
std::queue< _Tp, _Sequence >::back () const [inline]
Returns a read-only (constant) reference to the data at the last element of the queue.
References std::queue< _Tp, _Sequence >::c.
empty() const
template<typename _Tp , typename _Sequence = deque<_Tp>> bool std::queue<
_Tp, _Sequence >::empty () const [inline]
Returns true if the queue is empty.
References std::queue< _Tp, _Sequence >::c.
front()
template<typename _Tp , typename _Sequence = deque<_Tp>> reference
std::queue< _Tp, _Sequence >::front () [inline]
Returns a read/write reference to the data at the first element of the queue.
References std::queue< _Tp, _Sequence >::c.
front() const
template<typename _Tp , typename _Sequence = deque<_Tp>> const_reference
std::queue< _Tp, _Sequence >::front () const [inline]
Returns a read-only (constant) reference to the data at the first element of the queue.
References std::queue< _Tp, _Sequence >::c.
pop()
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.
β οΈ bestie, note that no data is returned, and if the first element's data is needed, it should be retrieved before pop() is called. Like, grab your snack before you yeet it. π
References std::queue< _Tp, _Sequence >::c.
push (const value_type &__x)
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.
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 std::queue< _Tp, _Sequence >::c.
size() const
template<typename _Tp , typename _Sequence = deque<_Tp>> size_type
std::queue< _Tp, _Sequence >::size () const [inline]
Returns the number of elements in the queue.
References std::queue< _Tp, _Sequence >::c.
π Member Data Documentation π
template<typename _Tp , typename _Sequence = deque<_Tp>> _Sequence
std::queue< _Tp, _Sequence >::c [protected]
c is the underlying container. The whole queue is lowkey built on this one protected member, and it's referenced by std::queue< _Tp, _Sequence >::back(), std::queue< _Tp, _Sequence >::back(), std::queue< _Tp, _Sequence >::empty(), std::queue< _Tp, _Sequence >::front(), std::queue< _Tp, _Sequence >::front(), std::operator<(), std::operator==(), std::queue< _Tp, _Sequence >::pop(), std::queue< _Tp, _Sequence >::push(), and std::queue< _Tp, _Sequence >::size(). Yes, back and front show up twice in that list β that's literally the list, I'm not editing it. π
π Author π
Generated automatically by Doxygen for libstdc++ from the source code. That's the author line, bestie β Doxygen did the typing, libstdc++ brought the lore. π«Ά
That's the whole page, bestie. Source/version: libstdc++. Manual section: 3cxx. Date: the page doesn't print one, so I'm not gonna manifest a fake date β periodt. π
π¦ where this page comes from
- ubuntu noble: libstdc++-14-doc 14-20240412-0ubuntu1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms