Contiguous sequence stored on Base's heap. More...
#include <StormByte/safe/vector.hxx>
Public Types | |
| using | value_type = T |
| Element type. | |
| using | size_type = Size |
| Element count. Size, not std::size_t. | |
| using | difference_type = std::ptrdiff_t |
| Iterator distance type. | |
| using | reference = T& |
| Mutable element reference. | |
| using | const_reference = const T& |
| Read-only element reference. | |
| using | pointer = T* |
| Mutable element pointer. | |
| using | const_pointer = const T* |
| Read-only element pointer. | |
| using | iterator = T* |
| Mutable contiguous iterator. | |
| using | const_iterator = const T* |
| Read-only contiguous iterator. | |
| using | reverse_iterator = std::reverse_iterator<iterator> |
| Mutable reverse iterator. | |
| using | const_reverse_iterator = std::reverse_iterator<const_iterator> |
| Read-only reverse iterator. | |
Public Member Functions | |
| Vector () noexcept | |
| Construct an empty sequence. | |
| Vector (size_type count) | |
Construct count value-initialized elements. | |
| Vector (size_type count, const T &value) | |
Construct count copies of value. | |
| template<std::input_iterator InputIt> | |
| Vector (InputIt first, InputIt last) | |
| Copy the range [first, last). | |
| Vector (std::initializer_list< T > values) | |
| Construct from an initializer list. | |
| Vector (const std::vector< T > &values) | |
| Copy a caller-owned STL vector. | |
| STORMBYTE_FORCE_INLINE | Vector (std::vector< T > &&values) |
| Move elements from a caller-owned STL vector and leave it empty. | |
| Vector (const Vector &other) | |
| Copy every element into a new Base block. | |
| Vector (Vector &&other) noexcept | |
| Take the block. | |
| ~Vector () noexcept | |
| Destroy every element and release the block. | |
| Vector & | operator= (const Vector &other) |
| Copy-assign. | |
| Vector & | operator= (Vector &&other) noexcept |
| Move-assign. | |
| Vector & | operator= (std::initializer_list< T > values) |
| Replace the contents with an initializer list. | |
| Vector & | operator= (const std::vector< T > &values) |
| Copy-assign a caller-owned STL vector. | |
| STORMBYTE_FORCE_INLINE Vector & | operator= (std::vector< T > &&values) |
| Move-assign elements from a caller-owned STL vector and leave it empty. | |
| iterator | begin () noexcept |
| Return a mutable iterator to the first element. | |
| iterator | end () noexcept |
| Return the mutable end iterator. | |
| const_iterator | begin () const noexcept |
| Return a read-only iterator to the first element. | |
| const_iterator | end () const noexcept |
| Return the read-only end iterator. | |
| const_iterator | cbegin () const noexcept |
| Return a read-only iterator to the first element. | |
| const_iterator | cend () const noexcept |
| Return the read-only end iterator. | |
| STORMBYTE_FORCE_INLINE reverse_iterator | rbegin () noexcept |
| Return a mutable reverse iterator to the last element. | |
| STORMBYTE_FORCE_INLINE reverse_iterator | rend () noexcept |
| Return the mutable reverse end iterator. | |
| STORMBYTE_FORCE_INLINE const_reverse_iterator | rbegin () const noexcept |
| Return a read-only reverse iterator to the last element. | |
| STORMBYTE_FORCE_INLINE const_reverse_iterator | rend () const noexcept |
| Return the read-only reverse end iterator. | |
| STORMBYTE_FORCE_INLINE const_reverse_iterator | crbegin () const noexcept |
| Return a read-only reverse iterator to the last element. | |
| STORMBYTE_FORCE_INLINE const_reverse_iterator | crend () const noexcept |
| Return the read-only reverse end iterator. | |
| bool | empty () const noexcept |
| Test whether the sequence is empty. | |
| size_type | size () const noexcept |
| Return the element count. | |
| STORMBYTE_FORCE_INLINE size_type | max_size () const noexcept |
| Return the largest representable element count. | |
| size_type | capacity () const noexcept |
| Return the allocated capacity. | |
| pointer | data () noexcept |
| Return a pointer to the block. | |
| const_pointer | data () const noexcept |
| Return a pointer to the block. | |
| STORMBYTE_FORCE_INLINE | operator std::span< T > () noexcept |
| Borrow the occupied elements. | |
| STORMBYTE_FORCE_INLINE | operator std::span< const T > () const noexcept |
| Borrow the occupied elements. | |
| void | reserve (size_type count) |
Reserve room for at least count elements. | |
| void | shrink_to_fit () |
| Release unused capacity. | |
| void | clear () noexcept |
| Destroy every element. | |
| void | swap (Vector &other) noexcept |
| Exchange blocks. | |
| reference | operator[] (size_type index) noexcept |
| Access an element. | |
| const_reference | operator[] (size_type index) const noexcept |
| Access an element. | |
| reference | at (size_type index) |
| Access an element. | |
| const_reference | at (size_type index) const |
| Access an element. | |
| reference | front () |
| Return the first element. | |
| const_reference | front () const |
| Return the first element. | |
| reference | back () |
| Return the last element. | |
| const_reference | back () const |
| Return the last element. | |
| void | push_back (const T &value) |
| Append a copy. | |
| void | push_back (T &&value) |
| Append a moved value. | |
| template<std::ranges::input_range R> | |
| void | append_range (R &&range) |
Append a copy of each element of range. | |
| void | pop_back () |
| Remove the last element. | |
| template<class... Args> | |
| reference | emplace_back (Args &&... args) |
| Construct an element at the end. | |
| iterator | insert (const_iterator position, const T &value) |
Insert a copy before position. | |
| iterator | insert (const_iterator position, T &&value) |
Insert a moved value before position. | |
| iterator | insert (const_iterator position, size_type count, const T &value) |
Insert count copies before position. | |
| template<std::input_iterator InputIt> | |
| iterator | insert (const_iterator position, InputIt first, InputIt last) |
Insert [first, last) before position. | |
| iterator | insert (const_iterator position, std::initializer_list< T > values) |
Insert an initializer list before position. | |
| template<std::ranges::input_range R> | |
| iterator | insert_range (const_iterator position, R &&range) |
Insert a copy of each element of range before position. | |
| template<class... Args> | |
| iterator | emplace (const_iterator position, Args &&... args) |
Construct an element before position. | |
| iterator | erase (const_iterator position) |
| Erase one element. | |
| iterator | erase (const_iterator first, const_iterator last) |
| Erase a half-open range. | |
| void | assign (size_type count, const T &value) |
Replace the contents with count copies. | |
| template<std::input_iterator InputIt> | |
| void | assign (InputIt first, InputIt last) |
| Replace the contents with [first, last). | |
| void | assign (std::initializer_list< T > values) |
| Replace the contents with an initializer list. | |
| template<std::ranges::input_range R> | |
| void | assign_range (R &&range) |
Replace the contents with a copy of range. | |
| void | resize (size_type count) |
| Change the size, value-initializing new elements. | |
| void | resize (size_type count, const T &value) |
Change the size, copying value into new elements. | |
| bool | operator== (const Vector &other) const |
| Compare elements in order. | |
| STORMBYTE_FORCE_INLINE std::strong_ordering | operator<=> (const Vector &other) const |
| Order sequences lexicographically. | |
| bool | operator< (const Vector &other) const |
| Order sequences lexicographically. | |
| bool | operator<= (const Vector &other) const |
| Order sequences lexicographically. | |
| bool | operator> (const Vector &other) const |
| Order sequences lexicographically. | |
| bool | operator>= (const Vector &other) const |
| Order sequences lexicographically. | |
| STORMBYTE_FORCE_INLINE | operator std::vector< T > () const |
| Copy the elements into caller-owned STL storage. | |
Contiguous sequence stored on Base's heap.
| T | Safe value. |
The block is allocated with Heap::Allocate. Iterators are pointers into that block. A move from std::vector moves the elements and clears the source in the caller, so its buffer is released by the caller's CRT. A range constructor copies elements. It does not adopt the source buffer. Conversion to std::span borrows the block and does not take ownership. There is no allocator: that would be the caller CRT.
| using StormByte::Safe::Vector< T >::const_iterator = const T* |
Read-only contiguous iterator.
| using StormByte::Safe::Vector< T >::const_pointer = const T* |
Read-only element pointer.
| using StormByte::Safe::Vector< T >::const_reference = const T& |
Read-only element reference.
| using StormByte::Safe::Vector< T >::const_reverse_iterator = std::reverse_iterator<const_iterator> |
Read-only reverse iterator.
| using StormByte::Safe::Vector< T >::difference_type = std::ptrdiff_t |
Iterator distance type.
| using StormByte::Safe::Vector< T >::iterator = T* |
Mutable contiguous iterator.
| using StormByte::Safe::Vector< T >::pointer = T* |
Mutable element pointer.
| using StormByte::Safe::Vector< T >::reference = T& |
Mutable element reference.
| using StormByte::Safe::Vector< T >::reverse_iterator = std::reverse_iterator<iterator> |
Mutable reverse iterator.
| using StormByte::Safe::Vector< T >::size_type = Size |
Element count. Size, not std::size_t.
| using StormByte::Safe::Vector< T >::value_type = T |
Element type.
|
noexcept |
Construct an empty sequence.
|
explicit |
Construct count value-initialized elements.
| count | Element count. |
| AllocationError | The block could not be allocated. |
| StormByte::Safe::Vector< T >::Vector | ( | size_type | count, |
| const T & | value ) |
Construct count copies of value.
| count | Element count. |
| value | Value to copy. |
| AllocationError | The block could not be allocated. |
| StormByte::Safe::Vector< T >::Vector | ( | InputIt | first, |
| InputIt | last ) |
Copy the range [first, last).
| InputIt | Input iterator whose value is convertible to T. |
| first | Start of the source range. |
| last | End of the source range. |
| AllocationError | The block could not be allocated. |
| StormByte::Safe::Vector< T >::Vector | ( | std::initializer_list< T > | values | ) |
Construct from an initializer list.
| values | Initial elements. |
| AllocationError | The block could not be allocated. |
|
explicit |
Copy a caller-owned STL vector.
Its state is unchanged.
| values | Source. |
| AllocationError | The block could not be allocated. |
|
inlineexplicit |
Move elements from a caller-owned STL vector and leave it empty.
| values | Source. Cleared before this function returns. |
| AllocationError | The block could not be allocated. |
| StormByte::Safe::Vector< T >::Vector | ( | const Vector< T > & | other | ) |
Copy every element into a new Base block.
| other | Source. |
| AllocationError | The block could not be allocated. |
|
noexcept |
Take the block.
other is left empty.
| other | Source. |
|
noexcept |
Destroy every element and release the block.
| void StormByte::Safe::Vector< T >::append_range | ( | R && | range | ) |
Append a copy of each element of range.
| R | Input range whose value is convertible to T. |
| range | Source range. Copied first when it refers to this sequence. |
| AllocationError | The block could not be allocated. |
| void StormByte::Safe::Vector< T >::assign | ( | InputIt | first, |
| InputIt | last ) |
Replace the contents with [first, last).
| InputIt | Input iterator whose value is convertible to T. |
| first | Start of the source range. |
| last | End of the source range. |
| AllocationError | The block could not be allocated. |
| void StormByte::Safe::Vector< T >::assign | ( | size_type | count, |
| const T & | value ) |
Replace the contents with count copies.
| count | Element count. |
| value | Value to copy. |
| AllocationError | The block could not be allocated. |
| void StormByte::Safe::Vector< T >::assign | ( | std::initializer_list< T > | values | ) |
Replace the contents with an initializer list.
| values | New elements. |
| AllocationError | The block could not be allocated. |
| void StormByte::Safe::Vector< T >::assign_range | ( | R && | range | ) |
Replace the contents with a copy of range.
| R | Input range whose value is convertible to T. |
| range | Source range. Copied first when it refers to this sequence. |
| AllocationError | The block could not be allocated. |
| reference StormByte::Safe::Vector< T >::at | ( | size_type | index | ) |
Access an element.
| index | Element index. |
| OutOfBoundsError | index is outside the sequence. |
| const_reference StormByte::Safe::Vector< T >::at | ( | size_type | index | ) | const |
Access an element.
| index | Element index. |
| OutOfBoundsError | index is outside the sequence. |
| reference StormByte::Safe::Vector< T >::back | ( | ) |
Return the last element.
| OutOfBoundsError | The sequence is empty. |
| const_reference StormByte::Safe::Vector< T >::back | ( | ) | const |
Return the last element.
| OutOfBoundsError | The sequence is empty. |
|
noexcept |
Return a read-only iterator to the first element.
|
noexcept |
Return a mutable iterator to the first element.
|
noexcept |
Return the allocated capacity.
|
noexcept |
Return a read-only iterator to the first element.
|
noexcept |
Return the read-only end iterator.
|
noexcept |
Destroy every element.
Capacity is kept.
|
inlinenoexcept |
Return a read-only reverse iterator to the last element.
|
inlinenoexcept |
Return the read-only reverse end iterator.
|
noexcept |
Return a pointer to the block.
|
noexcept |
Return a pointer to the block.
| iterator StormByte::Safe::Vector< T >::emplace | ( | const_iterator | position, |
| Args &&... | args ) |
Construct an element before position.
| Args | Constructor argument types. |
| position | Insertion point. |
| args | Arguments forwarded to T. |
| AllocationError | The block could not be allocated. |
| reference StormByte::Safe::Vector< T >::emplace_back | ( | Args &&... | args | ) |
Construct an element at the end.
| Args | Constructor argument types. |
| args | Arguments forwarded to T. |
| AllocationError | The block could not be allocated. |
|
noexcept |
Test whether the sequence is empty.
|
noexcept |
Return the read-only end iterator.
|
noexcept |
Return the mutable end iterator.
| iterator StormByte::Safe::Vector< T >::erase | ( | const_iterator | first, |
| const_iterator | last ) |
Erase a half-open range.
| first | First element to erase. |
| last | Past-the-end element. |
| iterator StormByte::Safe::Vector< T >::erase | ( | const_iterator | position | ) |
Erase one element.
| position | Element to erase. |
| reference StormByte::Safe::Vector< T >::front | ( | ) |
Return the first element.
| OutOfBoundsError | The sequence is empty. |
| const_reference StormByte::Safe::Vector< T >::front | ( | ) | const |
Return the first element.
| OutOfBoundsError | The sequence is empty. |
| iterator StormByte::Safe::Vector< T >::insert | ( | const_iterator | position, |
| const T & | value ) |
Insert a copy before position.
| position | Insertion point. |
| value | Value to copy. |
| AllocationError | The block could not be allocated. |
| iterator StormByte::Safe::Vector< T >::insert | ( | const_iterator | position, |
| InputIt | first, | ||
| InputIt | last ) |
Insert [first, last) before position.
| InputIt | Input iterator whose value is convertible to T. |
| position | Insertion point. |
| first | Start of the source range. |
| last | End of the source range. |
position when the range is empty. | AllocationError | The block could not be allocated. |
| iterator StormByte::Safe::Vector< T >::insert | ( | const_iterator | position, |
| size_type | count, | ||
| const T & | value ) |
Insert count copies before position.
| position | Insertion point. |
| count | Copy count. |
| value | Value to copy. |
position when count is zero. | AllocationError | The block could not be allocated. |
| iterator StormByte::Safe::Vector< T >::insert | ( | const_iterator | position, |
| std::initializer_list< T > | values ) |
Insert an initializer list before position.
| position | Insertion point. |
| values | Elements to insert. |
position when values is empty. | AllocationError | The block could not be allocated. |
| iterator StormByte::Safe::Vector< T >::insert | ( | const_iterator | position, |
| T && | value ) |
Insert a moved value before position.
| position | Insertion point. |
| value | Value to move. |
| AllocationError | The block could not be allocated. |
| iterator StormByte::Safe::Vector< T >::insert_range | ( | const_iterator | position, |
| R && | range ) |
Insert a copy of each element of range before position.
| R | Input range whose value is convertible to T. |
| position | Insertion point. |
| range | Source range. Copied first when it refers to this sequence. |
position when range is empty. | AllocationError | The block could not be allocated. |
|
inlinenoexcept |
Return the largest representable element count.
|
inlinenoexcept |
|
inlinenoexcept |
|
inlineexplicit |
Copy the elements into caller-owned STL storage.
| bool StormByte::Safe::Vector< T >::operator< | ( | const Vector< T > & | other | ) | const |
Order sequences lexicographically.
| other | Sequence to compare. |
other. | bool StormByte::Safe::Vector< T >::operator<= | ( | const Vector< T > & | other | ) | const |
Order sequences lexicographically.
| other | Sequence to compare. |
other. | STORMBYTE_FORCE_INLINE std::strong_ordering StormByte::Safe::Vector< T >::operator<=> | ( | const Vector< T > & | other | ) | const |
Order sequences lexicographically.
| other | Sequence to compare. |
| Vector & StormByte::Safe::Vector< T >::operator= | ( | const std::vector< T > & | values | ) |
Copy-assign a caller-owned STL vector.
Its state is unchanged.
| values | Source. |
| AllocationError | The block could not be allocated. |
| Vector & StormByte::Safe::Vector< T >::operator= | ( | const Vector< T > & | other | ) |
Copy-assign.
The previous block is released only after the copy exists.
| other | Source. |
| AllocationError | The block could not be allocated. |
| Vector & StormByte::Safe::Vector< T >::operator= | ( | std::initializer_list< T > | values | ) |
Replace the contents with an initializer list.
| values | New elements. |
| AllocationError | The block could not be allocated. |
|
inline |
Move-assign elements from a caller-owned STL vector and leave it empty.
| values | Source. Cleared before this function returns. |
| AllocationError | The block could not be allocated. |
|
noexcept |
Move-assign.
other is left empty.
| other | Source. |
| bool StormByte::Safe::Vector< T >::operator== | ( | const Vector< T > & | other | ) | const |
Compare elements in order.
| other | Sequence to compare. |
| bool StormByte::Safe::Vector< T >::operator> | ( | const Vector< T > & | other | ) | const |
Order sequences lexicographically.
| other | Sequence to compare. |
other. | bool StormByte::Safe::Vector< T >::operator>= | ( | const Vector< T > & | other | ) | const |
Order sequences lexicographically.
| other | Sequence to compare. |
other.
|
noexcept |
Access an element.
| index | Element index. |
|
noexcept |
Access an element.
| index | Element index. |
| void StormByte::Safe::Vector< T >::pop_back | ( | ) |
Remove the last element.
| OutOfBoundsError | The sequence is empty. |
| void StormByte::Safe::Vector< T >::push_back | ( | const T & | value | ) |
Append a copy.
| value | Value to copy. |
| AllocationError | The block could not be allocated. |
| void StormByte::Safe::Vector< T >::push_back | ( | T && | value | ) |
Append a moved value.
| value | Value to move. |
| AllocationError | The block could not be allocated. |
|
inlinenoexcept |
Return a read-only reverse iterator to the last element.
|
inlinenoexcept |
Return a mutable reverse iterator to the last element.
|
inlinenoexcept |
Return the read-only reverse end iterator.
|
inlinenoexcept |
Return the mutable reverse end iterator.
| void StormByte::Safe::Vector< T >::reserve | ( | size_type | count | ) |
Reserve room for at least count elements.
A smaller request does not shrink.
| count | Minimum capacity. |
| AllocationError | The block could not be allocated. |
| void StormByte::Safe::Vector< T >::resize | ( | size_type | count | ) |
Change the size, value-initializing new elements.
| count | New size. |
| AllocationError | The block could not be allocated. |
| void StormByte::Safe::Vector< T >::resize | ( | size_type | count, |
| const T & | value ) |
Change the size, copying value into new elements.
| count | New size. |
| value | Value to copy. |
| AllocationError | The block could not be allocated. |
| void StormByte::Safe::Vector< T >::shrink_to_fit | ( | ) |
Release unused capacity.
|
noexcept |
Return the element count.
|
noexcept |
Exchange blocks.
Does not allocate.
| other | Sequence to exchange with. |