51#include <initializer_list>
75 template<Type::SafeValue T>
95 template<
bool IsConst>
97 using LinkType = std::conditional_t<IsConst, const Link, Link>;
104 using reference = std::conditional_t<IsConst, const T&, T&>;
105 using pointer = std::conditional_t<IsConst, const T*, T*>;
117 template<
bool OtherConst>
118 requires IsConst && (!OtherConst)
125 reference operator*() const noexcept {
return static_cast<Node*
>(
const_cast<Link*
>(m_link))->Value; }
131 pointer operator->() const noexcept {
return &
static_cast<Node*
>(
const_cast<Link*
>(m_link))->Value; }
162 template<
bool OtherConst>
173 explicit BasicIterator(LinkType* link)
noexcept: m_link(link) {}
224 if (
this != &other) {
226 m_node = other.m_node;
227 other.m_node =
nullptr;
236 bool empty() const noexcept {
return m_node ==
nullptr; }
242 explicit operator bool() const noexcept {
return !
empty(); }
248 T&
value() {
return m_node->Value; }
254 const T&
value()
const {
return m_node->Value; }
269 explicit node_type(Node* node)
noexcept: m_node(node) {}
274 void reset() noexcept {
275 if (m_node ==
nullptr)
282 Node* m_node =
nullptr;
324 for (
const T& value : other)
334 for (T& value : other)
345 template<std::ranges::input_range R>
346 requires std::convertible_to<std::ranges::range_reference_t<R>, T>
356 List(std::initializer_list<T> values);
384 List& operator=(
std::initializer_list<T> values);
407 template<
std::ranges::input_range R>
408 requires
std::convertible_to<
std::ranges::range_reference_t<R>, T>
410 List replacement(std::from_range, std::forward<R>(range));
436 const T&
back() const noexcept { assert(!
empty());
return *std::prev(
end()); }
514 bool empty() const noexcept {
return m_size == 0; }
578 template<
std::ranges::input_range R>
579 requires
std::convertible_to<
std::ranges::range_reference_t<R>, T>
581 iterator first(
const_cast<Link*
>(position.m_link));
582 bool started =
false;
583 for (
auto&& value : range) {
584 iterator inserted =
insert(position, T(std::forward<
decltype(value)>(value)));
601 template<
class... Args>
640 template<
class... Args>
669 template<class... Args>
749 template<class Compare>
765 template<class Predicate>
785 template<class Predicate>
798 template<class Compare>
806 bool operator==(const
List& other) const;
821 for (
const T& value : *
this)
822 copied.push_back(value);
831 Link* Next =
nullptr;
832 Link* Prev =
nullptr;
846 template<
class... Args>
847 explicit Node(Args&&... args): Value(
std::forward<Args>(args)...) {}
853 void ResetSentinel() noexcept;
862 template<class... Args>
863 Node* MakeNode(Args&&... args);
870 void LinkBefore(Link* position, Node* node) noexcept;
876 void Unlink(Node* node) noexcept;
881 void Destroy() noexcept;
884 size_type m_size = 0;
893 template<Type::SafeValue T>
906 template<SafeValue T>
907 requires IsSafe<T>::value
914 template<SafeValue T>
922 template<SafeValue T>
Bidirectional cursor over Base-owned list nodes.
Definition list.hxx:96
std::conditional_t< IsConst, const T &, T & > reference
Element reference.
Definition list.hxx:104
T value_type
Element type.
Definition list.hxx:102
BasicIterator & operator--() noexcept
Move to the previous element.
Definition list.hxx:149
std::ptrdiff_t difference_type
Iterator distance type.
Definition list.hxx:103
std::bidirectional_iterator_tag iterator_concept
C++20 iterator concept.
Definition list.hxx:101
BasicIterator operator--(int) noexcept
Move to the previous element.
Definition list.hxx:155
std::conditional_t< IsConst, const T *, T * > pointer
Element pointer.
Definition list.hxx:105
BasicIterator & operator++() noexcept
Advance to the next element.
Definition list.hxx:137
friend class BasicIterator
Definition list.hxx:167
std::bidirectional_iterator_tag iterator_category
Iterator category.
Definition list.hxx:100
reference operator*() const noexcept
Return the element stored in the node.
Definition list.hxx:125
BasicIterator() noexcept
Construct a singular iterator.
Definition list.hxx:111
BasicIterator operator++(int) noexcept
Advance to the next element.
Definition list.hxx:143
friend class List
Definition list.hxx:166
void StormByteSafeCursor
Base cursor mark. Copying the cursor copies one link pointer.
Definition list.hxx:106
pointer operator->() const noexcept
Access the element stored in the node.
Definition list.hxx:131
&&!OtherConst BasicIterator(const BasicIterator< OtherConst > &other) noexcept
Convert a mutable iterator to a const iterator.
Definition list.hxx:119
bool operator==(const BasicIterator< OtherConst > &other) const noexcept
Compare link identity.
Definition list.hxx:163
Owning handle to one extracted Base node.
Definition list.hxx:189
~node_type()
Destroy the owned node, if any.
Definition list.hxx:210
node_type & operator=(const node_type &)=delete
Copying a node handle is not supported.
void swap(node_type &other) noexcept
Exchange owned nodes.
Definition list.hxx:260
node_type & operator=(node_type &&other) noexcept
Take the node.
Definition list.hxx:223
friend class List
Definition list.hxx:263
T & value()
Return the owned element.
Definition list.hxx:248
node_type() noexcept=default
Construct an empty handle.
const T & value() const
Return the owned element.
Definition list.hxx:254
bool empty() const noexcept
Test whether the handle owns a node.
Definition list.hxx:236
Doubly linked list stored on Base's heap.
Definition list.hxx:76
size_type remove_if(Predicate predicate)
Erase every element for which predicate is true.
iterator end() noexcept
Return the past-the-end iterator.
Definition list.hxx:448
BasicIterator< true > const_iterator
Read-only iterator.
Definition list.hxx:179
const T & front() const noexcept
Return the first element.
Definition list.hxx:424
iterator insert(const_iterator position, const T &value)
Insert a copy of value before position.
std::ptrdiff_t difference_type
Iterator distance type.
Definition list.hxx:84
size_type size() const noexcept
Return the element count.
Definition list.hxx:520
T value_type
Element type.
Definition list.hxx:82
const T & const_reference
Read-only element reference.
Definition list.hxx:86
List() noexcept
Construct an empty list.
void pop_back() noexcept
Destroy the last element.
void clear() noexcept
Destroy every element.
size_type unique()
Erase consecutive duplicates.
void reverse() noexcept
Reverse the chain.
void push_back(const T &value)
Copy value to the back.
reverse_iterator rbegin() noexcept
Return a reverse iterator to the last element.
Definition list.hxx:478
const_reverse_iterator crbegin() const noexcept
Return a reverse iterator to the last element.
Definition list.hxx:502
void push_front(T &&value)
Move value to the front.
List(std::initializer_list< T > values)
Insert every element of an initializer list.
const_reverse_iterator crend() const noexcept
Return the reverse past-the-end iterator.
Definition list.hxx:508
void resize(size_type count)
Grow or shrink to count.
T & emplace_front(Args &&... args)
Construct an element at the front.
T & back() noexcept
Return the last element.
Definition list.hxx:430
size_type remove(const T &value)
Erase every element equal to value.
iterator emplace(const_iterator position, Args &&... args)
Construct an element in place before position.
void splice(const_iterator position, List &other) noexcept
Relink every node of other before position.
~List() noexcept
Destroy every node through Base.
void merge(List &other)
Move the ordered nodes of other into this ordered list.
bool empty() const noexcept
Test whether the list holds no elements.
Definition list.hxx:514
STORMBYTE_FORCE_INLINE iterator insert_range(const_iterator position, R &&range)
Insert every element of range before position.
Definition list.hxx:580
const_iterator cend() const noexcept
Return the past-the-end iterator.
Definition list.hxx:472
BasicIterator< false > iterator
Mutable iterator.
Definition list.hxx:178
Size size_type
Element count. Size, not std::size_t.
Definition list.hxx:83
T & front() noexcept
Return the first element.
Definition list.hxx:418
const T & back() const noexcept
Return the last element.
Definition list.hxx:436
void assign(size_type count, const T &value)
Replace the contents with count copies of value.
STORMBYTE_FORCE_INLINE List(std::list< T > &&other)
Move elements from a caller-owned STL list and leave it empty.
Definition list.hxx:333
const_iterator cbegin() const noexcept
Return the first element.
Definition list.hxx:466
T & emplace_back(Args &&... args)
Construct an element at the back.
size_type max_size() const noexcept
Return the maximum element count this list can report.
Definition list.hxx:526
void pop_front() noexcept
Destroy the first element.
reverse_iterator rend() noexcept
Return the reverse past-the-end iterator.
Definition list.hxx:484
STORMBYTE_FORCE_INLINE List(std::from_range_t, R &&range)
Copy the elements of range.
Definition list.hxx:347
void swap(List &other) noexcept
Exchange chains.
std::reverse_iterator< const_iterator > const_reverse_iterator
Read-only reverse iterator.
Definition list.hxx:181
const_iterator begin() const noexcept
Return the first element.
Definition list.hxx:454
const_iterator end() const noexcept
Return the past-the-end iterator.
Definition list.hxx:460
node_type extract(const_iterator position)
Unlink the element at position.
STORMBYTE_FORCE_INLINE void assign_range(R &&range)
Replace the contents with range.
Definition list.hxx:409
T & reference
Mutable element reference.
Definition list.hxx:85
iterator erase(const_iterator position)
Erase the element at position.
const_reverse_iterator rend() const noexcept
Return the reverse past-the-end iterator.
Definition list.hxx:496
iterator erase(const_iterator first, const_iterator last)
Erase the half-open range [first, last).
const_reverse_iterator rbegin() const noexcept
Return a reverse iterator to the last element.
Definition list.hxx:490
void push_front(const T &value)
Copy value to the front.
void sort()
Sort the chain.
iterator begin() noexcept
Return the first element.
Definition list.hxx:442
std::reverse_iterator< iterator > reverse_iterator
Mutable reverse iterator.
Definition list.hxx:180
Count of abstract units (uint64_t storage).
Definition size.hxx:107
Recognizes a conditional Safe component after stripping cv and references.
Definition safe.hxx:301
Private Base heap used by StormByte::Safe::Shared, StormByte::Safe::Unique and StormByte::Safe::Clona...
void Free(void *pointer) noexcept
Release a block obtained from Allocate.
Owned values that cross a DLL without the caller's CRT.
void swap(Binary &left, Binary &right) noexcept
Exchange two sequences.
Definition binary.hxx:760
Root namespace of the StormByte suite.
Octet count. Defined in byte_size.hxx. Forwarded so Type::Numeral can name it.
Host-width-stable count (uint64_t), implicit only to std::size_t.
Recognizes types whose DLL-boundary safety depends on documented provider requirements.
Definition safe.hxx:262
Recognizes collection values with Base-controlled lifetime.
Definition safe.hxx:347
Recognizes Base Safe components, not universal ABI compatibility.
Definition safe.hxx:138
#define STORMBYTE_PUBLIC_TYPE
Definition visibility.h:57
#define STORMBYTE_PUBLIC
Definition visibility.h:52