A linked sequence with stable element positions and splice operations.
Standard-style names retain their familiar container meaning. The notes below explain lookup results, mutation, ownership, and Catalyst conveniences; only entirely obvious operations are left as declarations.
Exceptions escaping container operations are translated to CError. Direct iterator operations, element references, and calls through .std() follow the underlying type’s contracts.
CList
template<typename T, class Alloc = std::allocator<T>> class CList
Types, constants & data
using List = std::list<T, Alloc>;
using pointer = typename List::pointer;
using const_pointer = typename List::const_pointer;
using size_type = typename List::size_type;
using difference_type = typename List::difference_type;
using reference = typename List::reference;
using const_reference = typename List::const_reference;
using iterator = typename List::iterator;
using const_iterator = typename List::const_iterator;
using allocator_type = typename List::allocator_type;
using reverse_iterator = typename List::reverse_iterator;
using const_reverse_iterator = typename List::const_reverse_iterator;
Methods
CList() noexcept(std::is_nothrow_default_constructible_v<List>);
explicit CList(const Alloc& alloc) noexcept;
explicit CList(size_type n, const Alloc& alloc = cContainerDefault<Alloc>());
CList(size_type n, const T& value, const Alloc& alloc = cContainerDefault<Alloc>());
template<CInputIterator I> CList(I first, I last, const Alloc& alloc = cContainerDefault<Alloc>());
CList(const CList& x);
CList(CList&& x) noexcept(std::is_nothrow_move_constructible_v<List>);
CList(const CList& x, const std::type_identity_t<Alloc>& alloc);
CList(CList&& x, const std::type_identity_t<Alloc>& alloc);
CList(const List& x);
CList(List&& x) noexcept(std::is_nothrow_move_constructible_v<List>);
CList(const List& x, const std::type_identity_t<Alloc>& alloc);
CList(List&& x, const std::type_identity_t<Alloc>& alloc);
CList(std::initializer_list<T> values, const Alloc& alloc = cContainerDefault<Alloc>());
template<CContainerRange<T> R> CList(std::from_range_t, R&& range, const Alloc& alloc = cContainerDefault<Alloc>());
CList(CBuffer& b);
Creates an empty sequence, copies a range or initializer list, or creates n elements with an optional repeated value. The count constructor changes size rather than merely reserving capacity; the CBuffer overload restores a typed serialized sequence.
template<class... Args> static CList fromArgs(Args&&... args);
Builds a container with one element per argument, in argument order. Arguments are forwarded so move-only values can be supplied as rvalues.
static CList range(int64_t a, int64_t b);
static CList range(size_t size);
Builds consecutive values in [a, b), or [0, size) for the one-argument form. These overloads require a nonempty range (a < b).
CList& operator=(const CList& x);
CList& operator=(CList&& x) noexcept(std::is_nothrow_move_assignable_v<List>);
CList<T, Alloc>& operator=(std::initializer_list<value_type> il);
template<CInputIterator InputIterator> void assign(InputIterator first, InputIterator last);
void assign(size_type n, const T& u);
void assign(std::initializer_list<T> values);
Replaces all elements with the supplied count/value, iterator range, or initializer list. Existing element references and iterators may be invalidated.
Replaces the contents with the elements of a C++ range. Each range element must be convertible to the container element type.
iterator begin() noexcept;
const_iterator begin() const noexcept;
const_iterator cbegin() const noexcept;
iterator end() noexcept;
const_iterator end() const noexcept;
const_iterator cend() const noexcept;
reverse_iterator rbegin() noexcept;
const_reverse_iterator rbegin() const noexcept;
const_reverse_iterator crbegin() const noexcept;
reverse_iterator rend() noexcept;
const_reverse_iterator rend() const noexcept;
const_reverse_iterator crend() const noexcept;
cspan span() const noexcept;
cspan span(size_t start) const noexcept;
cspan span(size_t start, size_t endOffset) const noexcept;
Returns an index range. start skips initial indices; endOffset excludes that many indices at the end.
bool empty() const noexcept;
size_type size() const noexcept;
size_type max_size() const noexcept;
reference& operator[](size_t i);
const_reference& operator[](size_t i) const;
Walks from begin() to the requested zero-based position and returns that element. This is a linear-time operation and requires an index below size().
reference front() noexcept(noexcept(l_.front()));
const_reference front() const noexcept(noexcept(l_.front()));
Returns the first element by reference. The container must be nonempty.
reference back() noexcept(noexcept(l_.back()));
const_reference back() const noexcept(noexcept(l_.back()));
Returns the last element by reference. The list must be nonempty.
iterator find(const T& v);
Returns an iterator to the first equal element, or end() when absent. The search is linear.
bool hasIndex(size_t i) const;
Tests whether the index is below size(), without accessing or adding an element.
bool has(const T& v) const;
Reports whether an equal element occurs in the container.
iterator insert(const_iterator position, const T& x);
iterator insert(size_t index, const T& x);
iterator insert(const_iterator position, size_type n, const T& x);
template<CInputIterator InputIterator> iterator insert(const_iterator position, InputIterator first, InputIterator last);
iterator insert(const_iterator position, T&& value);
iterator insert(const_iterator position, std::initializer_list<T> values);
Inserts values before the supplied iterator position and returns an iterator to the first inserted element. Existing elements retain their iterators and references.
template<CContainerRange<T> R> iterator insert_range(const_iterator position, R&& range);
Inserts the elements of a C++ range before the supplied iterator. Returns an iterator to the first inserted element, or the insertion position for an empty range.
template<class... Args> iterator emplace(const_iterator position, Args&&... args);
Constructs an element before the given position from forwarded constructor arguments. Returns its iterator.
template<class S> CList& operator<<(S&& x);
Appends one element and returns this container, allowing chained appends.
void push_back(const T& x);
void push_back(T&& x);
template <class... Args> reference emplace_back(Args&&... args);
Constructs an element at the end from forwarded constructor arguments and returns a reference to it.
void append(const CList& l);
template<class S> void append(const CList<S>& l);
Appends the supplied container’s elements in order. The original contents remain at the beginning.
Adds a C++ range at the end, preserving the order of its elements. Existing contents remain at the beginning.
void push_front(const T& x);
void push_front(T&& value);
template <class... Args> reference emplace_front(Args&&... args);
Constructs an element at the beginning from forwarded constructor arguments and returns a reference to it.
Adds a C++ range at the beginning, preserving the range’s order before the existing elements.
iterator erase(size_t index);
iterator erase(const_iterator position);
iterator erase(const_iterator first, const_iterator last);
Removes an element or iterator range and returns the following iterator. The numeric-index overload walks from the beginning to find the position, so it is linear in the index.
void pop_back() noexcept(noexcept(l_.back()));
Removes the last element without returning it. The container must be nonempty; use popBack() to retain its value.
Removes and returns the last element. The container must be nonempty.
void pop_front() noexcept(noexcept(l_.front()));
Removes the first element without returning it. The container must be nonempty; use popFront() to retain its value.
Removes and returns the first element. The container must be nonempty.
template<class S> void clearExcept(const S& s);
Removes every element for which s.has(element) is false. The surviving elements retain their relative order.
void resize(size_type n);
void resize(size_type n, const T& value);
Changes the number of elements, removing trailing elements or appending default/value-initialized elements. It changes size(), unlike reserve().
void swap(CList& lst) noexcept(noexcept(l_.swap(lst.l_)));
void merge(CList& x);
template<class Compare> void merge(CList& x, Compare comp);
void merge(CList&& source);
template<class Compare> void merge(CList&& source, Compare compare);
Transfers elements from a list sorted with the same comparison into this sorted list. The source is emptied; compatible allocators are required.
void splice(const_iterator position, CList& x);
void splice(const_iterator position, CList& x, const_iterator i);
void splice(const_iterator position, CList& x, const_iterator first, const_iterator last);
void splice(const_iterator position, CList&& source);
void splice(const_iterator position, CList&& source, const_iterator item);
void splice(const_iterator position, CList&& source, const_iterator first, const_iterator last);
Transfers all, one, or a range of nodes from another list before the destination position. Elements are not copied, and iterators to transferred elements continue to refer to them; allocators must be compatible.
size_type remove(const T& value);
Removes all elements equal to the supplied value and returns the number removed.
template <class Predicate> size_type remove_if(Predicate pred);
Removes all elements for which the predicate returns true and returns the number removed.
size_type unique();
template<class BinaryPredicate> size_type unique(BinaryPredicate binary_pred);
Removes consecutive equivalent elements and returns the number removed. Sort first if the intention is to eliminate equal values throughout the list.
void sort();
template<class Compare> void sort(Compare comp);
Stably sorts the list using the supplied comparison, or element ordering by default. Existing element references and iterators remain valid.
Reverses list order in place while preserving the elements and their references.
const List& std() const noexcept;
List& std() noexcept;
Returns a reference to the underlying standard container. Mutations affect this object directly; calls through that reference bypass Catalyst exception translation.
operator const List&() const noexcept;
Borrows the underlying container for interoperability. This does not copy storage; references and iterators follow that container’s lifetime and invalidation rules.
operator List&() noexcept;
Borrows the underlying container for interoperability. This does not copy storage; references and iterators follow that container’s lifetime and invalidation rules.
allocator_type get_allocator() const noexcept;
Appends the container to a CBuffer; restore it with the buffer-taking constructor.
Returns the stream-formatted representation as a cstr; this is display text rather than the binary storage format.