Containers
CSVector
A bounded vector that stores a variable number of elements within a fixed capacity.
C++23
mc/CSVector.h
#include <mc/CSVector.h>Copy
Exceptions escaping container operations are translated to CError . Direct iterator operations, element references, and calls through .std() follow the underlying type’s contracts.
The capacity is a template argument. Capacity overflow throws CLengthError ; checked indexing throws COutOfRangeError .
Jump to a declaration · 46
CSVector
template<class T, uint32_t N> class CSVector
Types, constants & data
static constexpr uint32_t Size = N;
Methods
Stores up to N elements inside the object. A size-taking constructor value-initializes its elements; oversized initial contents raise CLengthError .
Builds consecutive values in [a, b), or [0, size). The result must fit the fixed capacity N.
iterator begin();
const_iterator begin() const;
iterator end();
const_iterator end() const;
cspan span() const;
cspan span(uint32_t start) const;
cspan span(uint32_t start, uint32_t endOffset) const;
Returns an index range. start skips initial indices; endOffset excludes that many indices at the end.
uint32_t capacity() const;
T& operator[](uint32_t i);
const T& operator[](uint32_t i) const;
Returns an element by zero-based index. An index outside the current size raises COutOfRangeError .
T& back();
const T& back() const;
Returns the final logical element. An empty vector raises COutOfRangeError .
T* data();
const T* data() const;
std::span<T> view();
std::span<const T> view() const;
Returns a borrowed span over the current elements. Keep the container alive and do not use the view after an operation that invalidates its storage.
iterator find(const T& x);
Returns an iterator to the first equal element, or end() when absent. The search is linear.
iterator insert(uint32_t i, const T& x);
iterator insert(iterator itr, const T& x);
Inserts before an index or a compatible iterator, shifting later elements. Capacity overflow raises CLengthError ; returns an iterator to the new element.
Appends one element and returns this container, allowing chained appends.
void push_back(const T& x);
Adds an element after the current contents. Raises CLengthError if the fixed capacity is already full.
Copies all source elements after the current contents. Checks that the complete result fits N before appending.
Removes an indexed element and shifts later elements left. An invalid index raises COutOfRangeError .
Reduces the logical size by one; an empty vector raises COutOfRangeError . The underlying element object remains in fixed storage.
Removes and returns the last element. The container must be nonempty.
Resets the logical size to zero. The fixed storage and its element objects remain alive until overwritten or the vector is destroyed.
bool operator==(const CSVector & v) const;
bool operator!=(const CSVector & v) const;
CSVector::iterator
Methods
iterator& operator++();
iterator operator++(int);
bool operator!=(const iterator& itr) const;
bool operator==(const iterator& itr) const;
iterator operator+(uint32_t i) const;
iterator operator-(uint32_t i) const;
Returns the zero-based position stored by this iterator. This is also available for the end iterator, whose index equals the vector size.
CSVector::const_iterator
Methods
const_iterator(const CSVector & v, uint32_t i);
const_iterator& operator++();
const_iterator operator++(int);
const T& operator*() const;
bool operator!=(const const_iterator& itr) const;
bool operator==(const const_iterator& itr) const;
const_iterator operator+(uint32_t i) const;
const_iterator operator-(uint32_t i) const;
Returns the zero-based position stored by this iterator. This is also available for the end iterator, whose index equals the vector size.
Free functions & types
Functions
template<class T, uint32_t N> inline std::ostream& operator<<(std::ostream& ostr, const CSVector <T, N>& v);