15#if HX_USE_MACROS_WITH_MODULE
16#error Header does not provide macros alone.
41 hxassertmsg(
this != &other_,
"self_assignment"); (void)other_;
80template<
typename T_,
typename deleter_t_=hxdefault_delete>
111#if HX_CPLUSPLUS < 202002L
114 hxconstexpr bool operator!=(const const_iterator& x_) const { return !(*this == x_); }
119 && this->m_current_node_ != this->m_sentinel_,
"invalid_iterator");
120 return *
static_cast<const T_*
>(m_current_node_);
125 && this->m_current_node_ != this->m_sentinel_,
"invalid_iterator");
126 return static_cast<const T_*
>(m_current_node_);
132 : m_current_node_(current_)
134 , m_sentinel_(sentinel_)
138#if (HX_HARDENING_MODE) == HX_HARDENING_MODE_DEBUG
162 && this->m_current_node_ != this->m_sentinel_,
"invalid_iterator");
163 return *
static_cast<T_*
>(this->m_current_node_);
168 && this->m_current_node_ != this->m_sentinel_,
"invalid_iterator");
169 return static_cast<T_*
>(this->m_current_node_);
208 template<
typename deleter_u_>
229 template<
typename deleter_u_>
245 template<
typename callable_t_>
249 template<
typename callable_t_>
254 template<
typename callable_t_>
258 template<
typename callable_t_>
277 template<
typename deleter_u_>
290 template<
typename deleter_u_>
310 template<
typename deleter_u_>
321 template<
typename deleter_u_>
339 template<
typename callable_t_,
typename deleter_u_>
345 template<
typename callable_t_>
374#include "detail/hxconstexpr_list.inl"
const_iterator - Bidirectional iterator over const nodes.
Definition hxconstexpr_list.hpp:88
constexpr bool operator==(const const_iterator &x_) const
Returns true if both iterators point to the same node.
constexpr const_iterator(void)
Constructs an iterator that must not be incremented or dereferenced.
Definition hxconstexpr_list.hpp:92
constexpr const_iterator & operator--(void)
Retreats to the previous node and returns this iterator.
constexpr const_iterator & operator++(void)
Advances to the next node and returns this iterator.
constexpr const T & operator*(void) const
Returns a const reference to the current node.
Definition hxconstexpr_list.hpp:117
constexpr const_iterator operator--(int)
Post-decrement: retreats to the previous node and returns the prior position.
constexpr const T * operator->(void) const
Returns a const pointer to the current node.
Definition hxconstexpr_list.hpp:123
constexpr const_iterator operator++(int)
Post-increment: advances to the next node and returns the prior position.
iterator - Bidirectional iterator over mutable nodes.
Definition hxconstexpr_list.hpp:145
constexpr iterator operator--(int)
Post-decrement: retreats to the previous node and returns the prior position.
constexpr iterator & operator++(void)
Advances to the next node and returns this iterator.
Definition hxconstexpr_list.hpp:152
constexpr iterator & operator--(void)
Retreats to the previous node and returns this iterator.
Definition hxconstexpr_list.hpp:156
constexpr T & operator*(void) const
Returns a mutable reference to the current node.
Definition hxconstexpr_list.hpp:160
constexpr iterator operator++(int)
Post-increment: advances to the next node and returns the prior position.
constexpr iterator(void)
Constructs an iterator that must not be incremented or dereferenced.
Definition hxconstexpr_list.hpp:149
constexpr T * operator->(void) const
Returns a mutable pointer to the current node.
Definition hxconstexpr_list.hpp:166
hxconstexpr_list_node - Intrusive doubly linked list node base.
Definition hxconstexpr_list.hpp:31
constexpr hxconstexpr_list_node(void)
Constructs an unlinked node.
Definition hxconstexpr_list.hpp:34
constexpr hxconstexpr_list_node(const hxconstexpr_list_node &)
Constructs an unlinked node.
Definition hxconstexpr_list.hpp:37
constexpr hxconstexpr_list_node & operator=(const hxconstexpr_list_node &other_)
Assigns nothing. List linkage of either node is not affected.
Definition hxconstexpr_list.hpp:40
hxconstexpr_list - An intrusive doubly linked list that takes ownership of nodes via a deleter_t call...
Definition hxconstexpr_list.hpp:81
constexpr const_iterator find_if(callable_t_ &&callable_) const
Finds the first node for which the predicate returns true.
constexpr iterator insert(const_iterator pos_, hxptr< T, deleter_u_ > &&ptr_)
insert - Inserts the node owned by ptr immediately before pos.
constexpr hxsize_t remove_if(callable_t_ &&callable_) noexcept
Removes all nodes for which predicate returns true, invoking the stored deleter on each removed node.
constexpr hxconstexpr_list(deleter_t_ deleter_=deleter_t_())
Constructs an empty list with an optional deleter instance.
constexpr hxsize_t remove_if(callable_t_ &&callable_, deleter_u_ &&deleter_) noexcept
Removes all nodes for which predicate returns true, invoking deleter on each removed node.
constexpr void for_each(callable_t_ &&callable_) const
Calls a function, lambda, or std::function on each node.
constexpr const T & front(void) const
Returns a const reference to the first node. The list must not be empty.
constexpr bool empty(void) const
Returns true if the list contains no nodes.
constexpr iterator insert(const_iterator pos_, T *ptr_)
insert - Inserts ptr immediately before pos.
constexpr const_iterator begin(void) const
Returns a const iterator to the first node, or end() if the list is empty.
constexpr void reverse(void)
Reverses the order of nodes in the list in-place.
constexpr const_iterator cbegin(void) const
Returns a const iterator to the first node, or cend() if the list is empty.
Definition hxconstexpr_list.hpp:200
constexpr deleter_t_ & deleter(void)
Returns a reference to the stored deleter.
constexpr void erase(const_iterator pos_) noexcept
Unlinks and deletes the node at pos if deleter is true then calls deleter on it.
constexpr iterator find_if(callable_t_ &&callable_)
Non-const version of find_if.
constexpr void for_each(callable_t_ &&callable_)
Non-const version of for_each.
constexpr iterator end(void)
Returns an iterator to the sentinel, representing one past the last node.
Definition hxconstexpr_list.hpp:219
constexpr void release_all(void)
Resets the list to empty without invoking the deleter on any node.
constexpr iterator push_front(T *ptr_)
push_front - Inserts ptr at the front of the list.
constexpr ~hxconstexpr_list(void)
Destroys the list by calling clear(), which invokes the deleter on every remaining node.
Definition hxconstexpr_list.hpp:185
constexpr hxsize_t size(void) const
Returns the number of nodes currently in the list.
Definition hxconstexpr_list.hpp:352
constexpr void clear(void)
Removes all nodes using the stored deleter.
Definition hxconstexpr_list.hpp:212
constexpr const_iterator cend(void) const
Returns a const iterator to the sentinel, representing one past the last node.
Definition hxconstexpr_list.hpp:203
constexpr void clear(deleter_u_ &&deleter_) noexcept
Removes all nodes, invoking deleter on each.
constexpr iterator insert_after(const_iterator pos_, T *ptr_)
insert_after - Inserts ptr immediately after pos.
constexpr iterator push_back(hxptr< T, deleter_u_ > &&ptr_)
push_back - Inserts the node owned by ptr at the back of the list.
T node_t
T - The node type stored in the list.
Definition hxconstexpr_list.hpp:85
constexpr hxptr< T, deleter_t_ > extract(const_iterator pos_)
extract - Returns an hxptr owning the node at pos after unlinking it from the list.
constexpr const_iterator end(void) const
Returns a const iterator to the sentinel, representing one past the last node.
constexpr iterator push_front(hxptr< T, deleter_u_ > &&ptr_)
push_front - Inserts the node owned by ptr at the front of the list.
constexpr T & back(void)
Returns a reference to the last node. The list must not be empty.
constexpr void erase(const_iterator pos_, deleter_u_ &&deleter_) noexcept
Unlinks the node at pos and if deleter is true then calls deleter on it.
constexpr const deleter_t_ & deleter(void) const
Returns a const reference to the stored deleter.
constexpr iterator push_back(T *ptr_)
push_back - Inserts ptr at the back of the list.
constexpr hxptr< T, deleter_t_ > pop_back(void)
pop_back - Returns an hxptr owning the last node.
constexpr const T & back(void) const
Returns a const reference to the last node. The list must not be empty.
constexpr void splice(const_iterator pos_, hxconstexpr_list &other_)
Transfers all nodes from other and inserts them before pos, taking ownership.
constexpr iterator insert_after(const_iterator pos_, hxptr< T, deleter_u_ > &&ptr_)
insert_after - Inserts the node owned by ptr immediately after pos.
constexpr iterator begin(void)
Returns an iterator to the first node, or end() if the list is empty.
Definition hxconstexpr_list.hpp:194
constexpr hxptr< T, deleter_t_ > pop_front(void)
pop_front - Returns an hxptr owning the first node.
constexpr T & front(void)
Returns a reference to the first node. The list must not be empty.
hxptr<T, deleter_t> - A unique owning pointer.
Definition hxptr.hpp:30
#define hxinline
hxinline - Force a function to be inlined into its callers.
Definition hxsettings.h:120
#define hxattr_nodiscard
hxattr_nodiscard - Indicates the caller should not discard the return value.
Definition hxsettings.h:89
#define hxconstexpr
hxconstexpr - Enables C++23 compatable constexpr usage for functions as that has support for destruct...
Definition hxsettings.h:263
A few utility functions and most standard C++ meta programming functions.
Provides core macros, memory management and feature detection.
#define hxassertmsg(x_,...)
hxassertmsg(bool x, ...) - Logs an error and terminates execution if x is false.
Definition libhatchet.h:101
#define hxnull
hxnull - The null pointer value for a given pointer type represented by the numeric constant 0.
Definition libhatchet.h:277
#define HX_HARDENING_MODE
HX_HARDENING_MODE - Library hardening level. See the README.md for levels.
Definition libhatchet.h:51
#define HX_HARDENING_MODE_DEBUG
HX_HARDENING_MODE_DEBUG - Provides comprehensive asserts and verbose output.
Definition libhatchet.h:64
ptrdiff_t hxsize_t
hxsize_t - A signed size type, same as ssize_t or ptrdiff_t.
Definition libhatchet.h:209