Containers
CArray
A fixed-size array with tuple access, standard array operations, and Catalyst conveniences.
#include <mc/CArray.h>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.
CArray is not an aggregate. Excess initializer-list elements throw CLengthError; omitted elements are value-initialized. Tuple integration supports structured binding and unqualified get.
Jump to a declaration · 61
Free functions & types
Types, constants & data
template<class Array, class... Args> concept CArrayInitializable = requires(Args&&... values){ Array{std::forward<Args>(values)...}; };
Functions
operator!=
operator<
operator>
operator>=
operator<=
operator<<
template<class T, size_t N> inline std::ostream& operator<<(std::ostream& ostr, const CArray<T, N>& v);
<deduction guide for CArray>
operator<=>
swap
get
template<size_t I, class T, size_t N> constexpr T& get(CArray<T, N>& value) noexcept;
template<size_t I, class T, size_t N> constexpr const T& get(const CArray<T, N>& value) noexcept;
template<size_t I, class T, size_t N> constexpr T&& get(CArray<T, N>&& value) noexcept;
template<size_t I, class T, size_t N> constexpr const T&& get(const CArray<T, N>&& value) noexcept;
Provides compile-time indexed access for tuple-style use and structured bindings. The index must be less than the array’s fixed size.
CArray
template<class T, size_t N> class CArrayTypes, constants & data
using Array = std::array<T, N>;
using value_type = T;
using iterator = typename Array::iterator;
using const_iterator = typename Array::const_iterator;
using reverse_iterator = typename Array::reverse_iterator;
using const_reverse_iterator = typename Array::const_reverse_iterator;
using reference = typename Array::reference;
using const_reference = typename Array::const_reference;
using indexed_type = reference;
using size_type = typename Array::size_type;
using difference_type = typename Array::difference_type;
using pointer = typename Array::pointer;
using const_pointer = typename Array::const_pointer;
Array a_;
Methods
CArray
constexpr CArray() requires(std::is_nothrow_default_constructible_v<Array>) = default;
constexpr CArray() requires(!std::is_nothrow_default_constructible_v<Array> && std::is_default_constructible_v<Array>);
constexpr CArray(const CArray& other) requires(std::is_nothrow_copy_constructible_v<Array>) = default;
constexpr CArray(const CArray& other) requires(!std::is_nothrow_copy_constructible_v<Array> && std::is_copy_constructible_v<Array>);
constexpr CArray(CArray&& other) requires(std::is_nothrow_move_constructible_v<Array>) = default;
constexpr CArray(CArray&& other) requires(!std::is_nothrow_move_constructible_v<Array> && std::is_move_constructible_v<Array>);
template<class... Args> requires(sizeof...(Args) > 0 && CArrayInitializable<Array, Args...>) constexpr CArray(Args&&... values);
constexpr CArray(std::initializer_list<value_type> values) requires(N == 0 || std::is_copy_constructible_v<T>);
constexpr CArray(const Array& values) noexcept(std::is_nothrow_copy_constructible_v<Array>) requires(std::is_copy_constructible_v<Array>);
constexpr CArray(Array&& values) noexcept(std::is_nothrow_move_constructible_v<Array>) requires(std::is_move_constructible_v<Array>);
CArray(CBuffer& b);
Creates fixed-size storage by default, from element values, from an array, or by decoding a buffer. Initializer lists may contain at most N values; omitted elements are value-initialized when possible. Default-initialized arithmetic elements should be assigned before being read.
operator=
constexpr CArray& operator=(const CArray& other) requires(std::is_nothrow_copy_assignable_v<Array>) = default;
constexpr CArray& operator=(const CArray& other) requires(!std::is_nothrow_copy_assignable_v<Array> && std::is_copy_assignable_v<Array>);
constexpr CArray& operator=(CArray&& other) requires(std::is_nothrow_move_assignable_v<Array>) = default;
constexpr CArray& operator=(CArray&& other) requires(!std::is_nothrow_move_assignable_v<Array> && std::is_move_assignable_v<Array>);
template<class L> requires CSame<L, std::initializer_list<value_type>> constexpr CArray& operator=(L&& values);
fill
constexpr void fill(const T& u);
Assigns the supplied value to every element without changing the fixed array size.
begin
constexpr iterator begin() noexcept;
constexpr const_iterator begin() const noexcept;
cbegin
constexpr const_iterator cbegin() const noexcept;
end
constexpr iterator end() noexcept;
constexpr const_iterator end() const noexcept;
cend
constexpr const_iterator cend() const noexcept;
rbegin
constexpr reverse_iterator rbegin() noexcept;
constexpr const_reverse_iterator rbegin() const noexcept;
crbegin
constexpr const_reverse_iterator crbegin() const noexcept;
rend
constexpr reverse_iterator rend() noexcept;
constexpr const_reverse_iterator rend() const noexcept;
crend
constexpr const_reverse_iterator crend() const noexcept;
span
constexpr cspan span() const noexcept;
constexpr cspan span(size_t start) const noexcept;
constexpr 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.
empty
constexpr bool empty() const noexcept;
size
constexpr size_type size() const noexcept;
max_size
constexpr size_type max_size() const noexcept;
operator[]
constexpr reference operator[](size_t n) noexcept;
constexpr const_reference operator[](size_t n) const noexcept;
Returns the element at a zero-based index. The index must be below size(); this is not a checked, recoverable out-of-range lookup.
at
constexpr const_reference at(size_t n) const;
constexpr reference at(size_t n);
Returns the element at a zero-based index. An invalid index raises COutOfRangeError.
get
template<size_t I> constexpr T& get() & noexcept;
template<size_t I> constexpr const T& get() const& noexcept;
template<size_t I> constexpr T&& get() && noexcept;
template<size_t I> constexpr const T&& get() const&& noexcept;
Accesses the element at compile-time index I, preserving constness and the value category of this array. This is the tuple-style access used by structured bindings.
front
constexpr reference front() noexcept;
constexpr const_reference front() const noexcept;
Returns the first element by reference. The container must be nonempty.
back
constexpr reference back() noexcept;
constexpr const_reference back() const noexcept;
constexpr reference back(size_t i);
constexpr const_reference back(size_t i) const;
Returns the last element, or the element i positions before it: back(0) is the last element. The container must contain the requested element.
data
constexpr value_type* data() noexcept;
constexpr const value_type* data() const noexcept;
view
constexpr std::span<T, N> view() noexcept;
constexpr std::span<const T, N> view() const noexcept;
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.
find
constexpr iterator find(const T& v);
constexpr const_iterator find(const T& v) const;
Returns an iterator to the first equal element, or end() when absent. The search is linear.
indexOf
constexpr size_t indexOf(const T& v) const;
Returns the matching index, or size() if no element matches.
hasIndex
constexpr bool hasIndex(size_t i) const;
Tests whether the index is below size(), without accessing or adding an element.
has
constexpr bool has(const T& v) const;
Reports whether an equal element occurs in the container.
swap
constexpr void swap(CArray& vec) noexcept(noexcept(a_.swap(vec.a_)));
reverse
constexpr void reverse();
Reverses element order in place.
std
constexpr const Array& std() const noexcept;
constexpr Array& std() noexcept;
Returns a reference to the underlying standard container. Mutations affect this object directly; calls through that reference bypass Catalyst exception translation.
store
void store(CBuffer& b) const;
Appends the container to a CBuffer; restore it with the buffer-taking constructor.
output
void output(std::ostream& ostr) const;
Writes comma-separated elements to the stream without the surrounding container brackets.
dump
cstr dump() const;
Returns the stream-formatted representation as a cstr; this is display text rather than the binary storage format.
std::tuple_size
template<class T, size_t N> struct tuple_size<mc::CArray<T, N>> : integral_constant<size_t, N>std::tuple_element
template<size_t I, class T, size_t N> struct tuple_element<I, mc::CArray<T, N>> : tuple_element<I, array<T, N>>