Containers
CArrayBuf
A non-owning view of contiguous elements, with dynamic or fixed extent.
#include <mc/CArrayBuf.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.
Bounds and element lifetime follow span rules. Operations on borrowed elements and iterators use the element type’s own exception behavior.
The referenced elements must outlive the view. .std() returns a std::span by value. A const view() exposes const elements; no ownership is transferred.
Jump to a declaration · 46
Free functions & types
Types, constants & data
template<class T> inline constexpr bool CArrayBufferSource_ = false;
template<class T, size_t N> inline constexpr bool CArrayBufferSource_<std::array<T, N>> = true;
template<class T, size_t N> inline constexpr bool CArrayBufferSource_<std::span<T, N>> = true;
template<class T, size_t N> inline constexpr bool CArrayBufferSource_<CArrayBuf<T, N>> = true;
Functions
operator<<
template<class T, size_t Extent> inline std::ostream& operator<<(std::ostream& ostr, const CArrayBuf<T, Extent>& values);
CArrayBuf
template<class T, size_t Extent> class CArrayBufTypes, constants & data
using Span = std::span<T, Extent>;
using element_type = typename Span::element_type;
using value_type = typename Span::value_type;
using size_type = typename Span::size_type;
using difference_type = typename Span::difference_type;
using pointer = typename Span::pointer;
using const_pointer = typename Span::const_pointer;
using reference = typename Span::reference;
using const_reference = typename Span::const_reference;
using iterator = T*;
using const_iterator = const T*;
using reverse_iterator = std::reverse_iterator<iterator>;
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
static constexpr size_t extent = Extent;
Methods
CArrayBuf
constexpr CArrayBuf() noexcept requires(Extent == 0 || Extent == std::dynamic_extent);
constexpr CArrayBuf(Span source) noexcept;
template<std::contiguous_iterator I> requires std::is_constructible_v<Span, I, size_type> constexpr explicit(Extent != std::dynamic_extent) CArrayBuf(I first, size_type count);
template<std::contiguous_iterator I, std::sized_sentinel_for<I> S> requires(!std::is_convertible_v<S, size_type> && std::is_constructible_v<Span, I, S>) constexpr explicit(Extent != std::dynamic_extent) CArrayBuf(I first, S last);
template<size_t N> requires(Extent == std::dynamic_extent || Extent == N) constexpr CArrayBuf(std::type_identity_t<T> (&values)[N]) noexcept;
template<class U, size_t N> requires std::is_constructible_v<Span, std::array<U, N>&> constexpr CArrayBuf(std::array<U, N>& values) noexcept;
template<class U, size_t N> requires std::is_constructible_v<Span, const std::array<U, N>&> constexpr CArrayBuf(const std::array<U, N>& values) noexcept;
template<class U, size_t N> requires std::is_constructible_v<Span, std::span<U, N>> constexpr explicit(Extent != std::dynamic_extent && N == std::dynamic_extent) CArrayBuf(const std::span<U, N>& source) noexcept;
template<class U, size_t N> requires std::is_constructible_v<Span, std::span<U, N>> constexpr explicit(Extent != std::dynamic_extent && N == std::dynamic_extent) CArrayBuf(const CArrayBuf<U, N>& source) noexcept;
template<class R> requires(!CArrayBufferSource_<std::remove_cvref_t<R>> && !std::is_array_v<std::remove_reference_t<R>> && std::is_constructible_v<Span, R>) constexpr explicit(Extent != std::dynamic_extent) CArrayBuf(R&& range);
constexpr CArrayBuf(const CArrayBuf&) noexcept = default;
Creates a view over existing contiguous storage without copying or owning elements. The supplied range must satisfy the fixed extent when one is specified, and its elements must outlive the view.
operator=
begin
constexpr iterator begin() const noexcept;
cbegin
constexpr const_iterator cbegin() const noexcept;
end
constexpr iterator end() const noexcept;
cend
constexpr const_iterator cend() const noexcept;
rbegin
constexpr reverse_iterator rbegin() const noexcept;
crbegin
constexpr const_reverse_iterator crbegin() const noexcept;
rend
constexpr 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;
size_bytes
constexpr size_type size_bytes() const noexcept;
operator[]
constexpr reference operator[](size_type i) 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.
front
constexpr reference front() const noexcept;
Returns the first element by reference. The container must be nonempty.
back
constexpr reference back() const noexcept;
Returns the last element by reference. The view must be nonempty.
first
template<size_t Count> constexpr CArrayBuf<T, Count> first() const noexcept;
constexpr CArrayBuf<T> first(size_type count) const noexcept;
Returns a view over the first count elements. The requested count must fit within the original view.
last
template<size_t Count> constexpr CArrayBuf<T, Count> last() const noexcept;
constexpr CArrayBuf<T> last(size_type count) const noexcept;
Returns a view over the final count elements. The requested count must fit within the original view.
data
constexpr pointer data() const noexcept;
view
constexpr std::span<T> view() noexcept;
constexpr std::span<const T> 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.
subspan
template<size_t Offset, size_t Count = std::dynamic_extent> constexpr auto subspan() const noexcept;
constexpr CArrayBuf<T> subspan(size_type offset, size_type count = std::dynamic_extent) const noexcept;
Returns a view beginning at the specified offset, optionally limited to a count. The offset and count must lie within the original view; no elements are copied.
find
constexpr iterator find(const T& value) const;
Returns an iterator to the first equal element, or end() when absent. The search is linear.
indexOf
constexpr size_t indexOf(const T& value) const;
Returns the matching index, or size() if no element matches.
std
constexpr Span std() const noexcept;
Returns the underlying std::span by value. The returned span still borrows the same elements.
dump
cstr dump() const;
Returns the stream-formatted representation as a cstr; this is display text rather than the binary storage format.