5#ifndef INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_INTRUSIVE_QUEUE_HPP_
6#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_INTRUSIVE_QUEUE_HPP_
10#include "arene/base/contracts.hpp"
11#include "arene/base/intrusive/detail/default_tag.hpp"
12#include "arene/base/intrusive/singly_linked_node.hpp"
13#include "arene/base/stdlib_choice/cstddef.hpp"
14#include "arene/base/stdlib_choice/exchange.hpp"
15#include "arene/base/stdlib_choice/is_base_of.hpp"
16#include "arene/base/stdlib_choice/is_const.hpp"
17#include "arene/base/stdlib_choice/move.hpp"
18#include "arene/base/utility/swap.hpp"
48 using const_reference = T
const&;
51 explicit constexpr queue()
noexcept =
default;
68 queue temp{std::move(other)};
97 constexpr auto front()
noexcept -> reference {
99 return static_cast<reference>(*head_);
105 constexpr auto back()
noexcept -> reference {
107 return static_cast<reference>(*tail_);
116 constexpr auto empty()
const noexcept ->
bool {
return size() == size_type{}; }
121 constexpr void push(reference value)
noexcept {
123 ARENE_PRECONDITION(!value.linked_node::is_linked());
125 head_ =
static_cast<linked_node*>(&value);
128 get_next_link(*tail_, Tag{}, detail::singly_linked_node_pass_key{}) = &value;
129 tail_ =
static_cast<linked_node*>(&value);
133 get_next_link(value, Tag{}, detail::singly_linked_node_pass_key{}) =
static_cast<linked_node*>(&value);
140 constexpr void pop()
noexcept {
141 ARENE_PRECONDITION(!empty());
143 get_next_link(*head_, Tag{}, detail::singly_linked_node_pass_key{}) =
nullptr;
147 auto prev_head = head_;
148 head_ = get_next_link(*head_, Tag{}, detail::singly_linked_node_pass_key{});
149 get_next_link(*prev_head, Tag{}, detail::singly_linked_node_pass_key{}) =
nullptr;
158 swap(size_, other.size_);
159 swap(head_, other.head_);
160 swap(tail_, other.tail_);
167 constexpr auto operator==(
queue const& other)
const noexcept ->
bool =
delete;
173 constexpr auto operator!=(
queue const& other)
const noexcept ->
bool =
delete;
180 linked_node* head_{
nullptr};
182 linked_node* tail_{
nullptr};
Intrusive queue implementation.
Definition queue.hpp:33
constexpr queue(queue &&other) noexcept
Move constructor.
Definition queue.hpp:55
constexpr queue() noexcept=default
Default constructor.
constexpr void pop() noexcept
Remove the front element from the queue.
Definition queue.hpp:140
constexpr auto back() noexcept -> reference
Get the reference to the back element of the queue.
Definition queue.hpp:105
constexpr auto size() const noexcept -> size_type
Get the size of the queue.
Definition queue.hpp:112
constexpr auto operator=(queue &&other) noexcept -> queue &
Move assignment operator.
Definition queue.hpp:63
constexpr auto operator==(queue const &other) const noexcept -> bool=delete
deleted equality operator
auto operator=(queue const &) -> queue &=delete
Deleted copy assignment operator.
queue(queue const &)=delete
Deleted copy constructor.
constexpr void push(reference value) noexcept
Push an element into the queue.
Definition queue.hpp:121
constexpr auto empty() const noexcept -> bool
Check if the queue is empty.
Definition queue.hpp:116
constexpr auto operator!=(queue const &other) const noexcept -> bool=delete
deleted equality operator
constexpr auto front() noexcept -> reference
Get the reference to the front element of the queue.
Definition queue.hpp:97
constexpr void swap(queue &other) noexcept
Swap the contents of two queues.
Definition queue.hpp:156
~queue()=default
Trivial destructor. This is a tradeoff. C++14 doesn't allow user-provided destructor to be constexpr.
Definition binary_tree_node.hpp:14
Definition array_exceptions_disabled.cpp:11
Copyright 2026, Toyota Motor Corporation.
Definition array_exceptions_disabled.cpp:10