5#ifndef INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_INTRUSIVE_QUEUE_HPP_
6#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_INTRUSIVE_QUEUE_HPP_
11#include "arene/base/intrusive/detail/default_tag.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"
32template <
typename T,
typename Tag = detail::default_tag>
51 explicit constexpr queue() noexcept = default;
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 {
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_);
180 linked_node* head_{
nullptr};
182 linked_node* tail_{
nullptr};
std::size_t size_type
size type
Definition queue.hpp:44
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
T const & const_reference
const reference type
Definition queue.hpp:48
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.
T value_type
value type
Definition queue.hpp:42
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
T & reference
reference type
Definition queue.hpp:46
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.
Singly linked hook. User type can be derived from this class to support intrusive containers.
Definition singly_linked_node.hpp:45
static constexpr value_type value
Definition integral_constant.hpp:34
#define ARENE_PRECONDITION(condition)
Check that a precondition holds, and terminate the application if it does not.
Definition contract.hpp:150
Public export header for the contracts subpackage.
Definition binary_tree_node.hpp:14
static ARENE_MAYBE_UNUSED constexpr auto const & swap
A Customization Point Object implementation of the constexpr compatible std::swap from C++17.
Definition swap.hpp:130
Definition accumulate.hpp:37
Definition accumulate.hpp:36
constexpr auto move(T &&value) noexcept -> remove_reference_t< T > &&
Cast a value to an rvalue.
Definition move.hpp:30
::size_t size_t
A type suitable for holding the size of an object.
Definition cstddef.hpp:29
constexpr auto exchange(T &target, U &&source) noexcept(is_nothrow_move_constructible_v< T > &&is_nothrow_assignable_v< T &, U && >) -> T
Assign a new value to an object and return the old value. Implements std::exchange.
Definition exchange.hpp:33