24#ifndef MICRO_OS_PLUS_UTILS_LISTS_INLINES_H_
25#define MICRO_OS_PLUS_UTILS_LISTS_INLINES_H_
34#pragma GCC diagnostic push
36#pragma GCC diagnostic ignored "-Waggregate-return"
38#pragma clang diagnostic ignored "-Wc++98-compat"
119#pragma GCC diagnostic push
121#if defined(__GNUC__) && !defined(__clang__)
122#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
159#pragma GCC diagnostic pop
194#pragma GCC diagnostic push
196#if defined(__clang__)
197#pragma GCC diagnostic ignored "-Wdocumentation-unknown-command"
219#pragma GCC diagnostic pop
284 template <
class T,
class N,
class U>
297 template <
class T,
class N,
class U>
305 template <
class T,
class N,
class U>
308 : node_{ &(element.*MP) }
310 static_assert (std::is_convertible<U, T>::value ==
true,
311 "U must be implicitly convertible to T!");
323 template <
class T,
class N,
class U>
341 template <
class T,
class N,
class U>
356 template <
class T,
class N,
class U>
372 template <
class T,
class N,
class U>
376 const auto tmp = *
this;
389 template <
class T,
class N,
class U>
405 template <
class T,
class N,
class U>
409 const auto tmp = *
this;
422 template <
class T,
class N,
class U>
438 template <
class T,
class N,
class U>
453 template <
class T,
class N,
class U>
485 template <
class T,
class L>
488#if defined(MICRO_OS_PLUS_TRACE_UTILS_LISTS_CONSTRUCT)
489 trace::printf (
"%s() @%p \n", __func__,
this);
492 if constexpr (is_statically_allocated::value)
515 template <
class T,
class L>
518#if defined(MICRO_OS_PLUS_TRACE_UTILS_LISTS_CONSTRUCT)
519 trace::printf (
"%s() @%p \n", __func__,
this);
524#if defined(MICRO_OS_PLUS_TRACE_UTILS_LISTS)
527 trace::printf (
"%s() @%p list not empty\n", __func__,
this);
540 template <
class T,
class L>
544 if constexpr (is_statically_allocated::value)
546 return links_.uninitialized ();
566 template <
class T,
class L>
570 if constexpr (is_statically_allocated::value)
572 links_.initialize_once ();
583 template <
class T,
class L>
588 return !links_.linked ();
599 template <
class T,
class L>
603#if defined(MICRO_OS_PLUS_TRACE_UTILS_LISTS)
604 trace::printf (
"%s() @%p\n", __func__,
this);
606 links_.initialize ();
617 template <
class T,
class L>
632 template <
class T,
class L>
636 return reinterpret_cast<pointer> (links_.previous ());
647 template <
class T,
class L>
651 if constexpr (is_statically_allocated::value)
653 assert (!
links_.uninitialized ());
657 tail ()->link_next (&node);
668 template <
class T,
class L>
672 if constexpr (is_statically_allocated::value)
674 assert (!
links_.uninitialized ());
678 head ()->link_previous (&node);
689 template <
class T,
class L>
693 if constexpr (is_statically_allocated::value)
695 assert (!
links_.uninitialized ());
709 template <
class T,
class L>
734 template <
class T,
class N, N T::* MP,
class U>
748 template <
class T,
class N, N T::* MP,
class U>
763 template <
class T,
class N, N T::* MP,
class U>
766 :
node_{ &(element.*MP) }
768 static_assert (std::is_convertible<U, T>::value ==
true,
769 "U must be implicitly convertible to T!");
780 template <
class T,
class N, N T::* MP,
class U>
784 return get_pointer ();
798 template <
class T,
class N, N T::* MP,
class U>
813 template <
class T,
class N, N T::* MP,
class U>
829 template <
class T,
class N, N T::* MP,
class U>
833 const auto tmp = *
this;
846 template <
class T,
class N, N T::* MP,
class U>
862 template <
class T,
class N, N T::* MP,
class U>
866 const auto tmp = *
this;
879 template <
class T,
class N, N T::* MP,
class U>
895 template <
class T,
class N, N T::* MP,
class U>
912 template <
class T,
class N, N T::* MP,
class U>
922 &(
static_cast<T*
> (
nullptr)->*MP));
936 template <
class T,
class N, N T::* MP,
class U>
960 template <
class T,
class N, N T::* MP,
class L,
class U>
972 template <
class T,
class N, N T::* MP,
class L,
class U>
988 template <
class T,
class N, N T::* MP,
class L,
class U>
1002 template <
class T,
class N, N T::* MP,
class L,
class U>
1018 template <
class T,
class N, N T::* MP,
class L,
class U>
1027 &(
static_cast<T*
> (
nullptr)->*MP));
1031 ->link_next (
reinterpret_cast<N*
> (
1044 template <
class T,
class N, N T::* MP,
class L,
class U>
1053 &(
static_cast<T*
> (
nullptr)->*MP));
1057 ->link_previous (
reinterpret_cast<N*
> (
1061#if defined(__GNUC__)
1062#pragma GCC diagnostic push
1063#pragma GCC diagnostic ignored "-Waggregate-return"
1074 template <
class T,
class N, N T::* MP,
class L,
class U>
1092 template <
class T,
class N, N T::* MP,
class L,
class U>
1104#if defined(__GNUC__)
1105#pragma GCC diagnostic pop
1117 template <
class T,
class N, N T::* MP,
class L,
class U>
1127 &(
static_cast<T*
> (
nullptr)->*MP));
1143 template <
class T,
class N, N T::* MP,
class L,
class U>
1165 template <
class T,
class N, N T::* MP,
class L,
class U>
1182#if defined(__GNUC__)
1183#pragma GCC diagnostic pop
A class template for a doubly linked list forward iterator.
constexpr bool operator==(const double_list_iterator &other) const
Equality comparison operator.
constexpr iterator_pointer get_iterator_pointer(void) const
Get the internal iterator pointer (node pointer).
constexpr pointer operator->() const
Pointer access operator.
value_type * pointer
Type of pointer to object pointed to by the iterator.
constexpr pointer get_pointer(void) const
Get a pointer to the value pointed to by the iterator.
constexpr double_list_iterator & operator--()
Pre-decrement operator.
constexpr bool operator!=(const double_list_iterator &other) const
Inequality comparison operator.
constexpr double_list_iterator & operator++()
Pre-increment operator.
constexpr reference operator*() const
Dereference operator.
value_type & reference
Type of reference to object pointed to by the iterator.
iterator_pointer node_
Pointer to the node.
constexpr double_list_iterator()
Default constructor. Constructs an iterator pointing to nullptr.
N * iterator_pointer
Type of reference to the iterator internal pointer.
A base class for a doubly linked list node.
constexpr ~double_list_links_base()
Destruct the node.
double_list_links_base * previous_
Pointer to the previous node.
constexpr double_list_links_base()
Construct an uninitialised list node.
constexpr double_list_links_base * next(void) const
Get the link to the next node.
constexpr double_list_links_base * previous(void) const
Get the link to the previous node.
double_list_links_base * next_
Pointer to the next node.
constexpr void initialize(void)
Initialise the node links.
constexpr double_list_links()
Construct a list node (initialise the pointers).
constexpr ~double_list_links()
Destruct the node.
constexpr const links_type * links_pointer(void) const
Get the address of the node storing the list links.
void link_head(reference node)
Add a node to the head of the list.
links_type links_
The list top node used to point to head and tail nodes.
L links_type
Type of the links node object where the pointers to the list head and tail are stored.
value_type * iterator_pointer
Type of reference to the iterator internal pointer.
constexpr pointer tail(void) const
Get the list tail.
void initialize_once(void)
Initialize the list only at first run.
value_type * pointer
Type of pointer to object pointed to by the iterator.
constexpr ~double_list()
Destruct the list.
value_type & reference
Type of reference to object pointed to by the iterator.
double_list()
Construct a doubly linked list.
void clear(void)
Clear the list.
constexpr pointer head(void) const
Get the list head.
iterator end() const
Iterator end.
iterator begin() const
Iterator begin.
double_list_iterator< value_type > iterator
Type of iterator over the values.
bool empty(void) const
Check if the list is empty.
void link_tail(reference node)
Add a node to the tail of the list.
bool uninitialized(void) const
Check if the list is uninitialised (only statically allocated lists can be uninitialised).
A class template for the intrusive list iterator.
value_type * pointer
Type of pointer to object pointed to by the iterator.
pointer get_pointer(void) const
Get the object node from the intrusive node.
intrusive_list_iterator & operator++()
Pre-increment operator.
iterator_pointer get_iterator_pointer(void) const
Retrieve the iterator pointer for the current node.
N * iterator_pointer
Type of reference to the iterator internal pointer.
reference operator*() const
Dereference operator.
bool operator==(const intrusive_list_iterator &other) const
Equality comparison operator.
value_type & reference
Type of reference to object pointed to by the iterator.
constexpr intrusive_list_iterator()
Default constructor. Constructs an iterator pointing to nullptr.
bool operator!=(const intrusive_list_iterator &other) const
Inequality comparison operator.
pointer operator->() const
Pointer access operator.
intrusive_list_iterator & operator--()
Pre-decrement operator.
ptrdiff_t difference_type
Type of pointer difference.
iterator_pointer node_
Pointer to intrusive node.
constexpr intrusive_list()
Construct an intrusive doubly linked list.
constexpr bool empty(void) const
Check if the list is empty.
void link_tail(reference node)
Add a node to the tail of the list.
N * iterator_pointer
Type of reference to the iterator internal pointer.
iterator begin() const
Iterator begin.
pointer unlink_head(void)
Unlink the first element from the list.
void link_head(reference node)
Add a node to the head of the list.
constexpr ~intrusive_list()
Destruct the list.
intrusive_list_iterator< T, N, MP, U > iterator
Type of iterator over the values.
void initialize_once(void)
Initialize the list only at first run.
iterator end() const
Iterator begin.
ptrdiff_t difference_type
Type of pointer difference.
value_type * pointer
Type of pointer to object pointed to by the iterator.
pointer unlink_tail(void)
Unlink the last element from the list.
pointer get_pointer(iterator_pointer node) const
Get the address of the object from the intrusive node pointer.
constexpr static_double_list_links()
Construct a statically allocated list node (BSS initialised).
constexpr ~static_double_list_links()
Destruct the node.
The µOS++ utilities definitions.