cptr::detail::basic_forward_list

The class behind cptr::forward_list; use that alias. Its members behave like those of std::forward_list; the alias lists the differences.

Synopsis

Declared in <cptr/forward_list.hpp>

template<
    class T,
    class Cage,
    bool Compressed>
class basic_forward_list;

Description

The list behind cptr::forward_list. Compressed = false gives the same list with raw 8-byte links, for the benchmarks.

The head link lives in the list object, which serves as before_begin(). No node ever links to it, so the object itself can be anywhere, and an empty list allocates nothing. A node of a 4-byte value is 8 bytes.

Types

Name
basic_iterator

Type Aliases

Name
const_iterator
const_reference
difference_type
iterator
reference
size_type
value_type

Member Functions

NameDescription
basic_forward_list [constructor]Constructors
~basic_forward_list [destructor]Destructor
operator= Assignment operators
assign
before_begin
begin
cbefore_begin
cbegin
cend
clear
emplace_after Construct an element from args after pos. Like std, it direct-initialises the element, so only the conversions std accepts compile.
emplace_front
empty
end
erase_after erase_after overloads
front
insert_after Returns the last element inserted, or pos if none.
max_size
merge Merge sorted other into this sorted list; stable, this list's elements come first among equals. If comp throws, the elements merged so far and the rest of this list stay here, the rest of other stays in other, and the exception propagates.
pop_front
push_front
remove Erase the elements equal to value and return how many. Unlinked nodes are destroyed only at the end, so value may refer to an element of this list. If a comparison throws, the elements already found are erased, the rest are kept, and the exception propagates.
remove_if Erase the elements for which pred is true and return how many. If pred throws, the elements already found are erased, the rest are kept, and the exception propagates.
resize
reverse
sort Stable merge sort on the links; no element is copied or moved. If comp throws, the list keeps all its elements in an unspecified order and the exception propagates.
splice_after splice_after overloads
swap
unique Erase all but the first of each run of consecutive elements for which pred is true, and return how many were erased. If pred throws, the elements already found are erased and the exception propagates.

Static Data Members

NameDescription
node_size Bytes per element, including the link: what the cage hands out.

Friends

NameDescription
cptr::detail::operator<=>Lexicographical, with std's synth-three-way: elements that have only operator< give a std::weak_ordering.
cptr::detail::operator==Equality operator
cptr::detail::swap