Skip to content

ludus::foundation::BorrowedView

Ludus Wiki · API overview · Browse API

Class

Non-owning contiguous elements with an explicit extent. No allocation or lifetime extension. The caller keeps the storage alive and unmoved while using the view. Const ElementType provides read-only access. A null pointer with a nonzero extent is invalid; consumers must check IsValid before accessing elements. Empty views mean no elements.

Declared in modules/foundation/containers/include/ludus/foundation/containers/borrowed_view.hpp

#include <ludus/foundation/containers/borrowed_view.hpp>
template <typename ElementType>
class ludus::foundation::BorrowedView final

Methods

BorrowedView

constexpr ludus::foundation::BorrowedView< ElementType >::BorrowedView() noexcept=default
Construct an empty valid view without allocating.

Declared in modules/foundation/containers/include/ludus/foundation/containers/borrowed_view.hpp

BorrowedView

constexpr ludus::foundation::BorrowedView< ElementType >::BorrowedView(ElementType *dataOrNull, usize count) noexcept
Borrow count elements; storage validity/lifetime remains the caller's responsibility.
ParameterDescription
dataOrNull
Null is allowed only when count is zero for a valid view.
count
Number of elements, not bytes. Construction preserves invalid input for validation.

Related types: usize

Declared in modules/foundation/containers/include/ludus/foundation/containers/borrowed_view.hpp

BorrowedView

template <usize Count>
constexpr ludus::foundation::BorrowedView< ElementType >::BorrowedView(ElementType(&inoutElements)[Count]) noexcept
Borrow a built-in array, preserving its extent without allocating or copying.

Related types: usize

Declared in modules/foundation/containers/include/ludus/foundation/containers/borrowed_view.hpp

IsValid

constexpr bool ludus::foundation::BorrowedView< ElementType >::IsValid() const noexcept
Whether the pointer/extent pair permits access; does not prove storage lifetime.

Declared in modules/foundation/containers/include/ludus/foundation/containers/borrowed_view.hpp

IsEmpty

constexpr bool ludus::foundation::BorrowedView< ElementType >::IsEmpty() const noexcept
Whether no elements are present; an invalid nonzero extent is not empty.

Declared in modules/foundation/containers/include/ludus/foundation/containers/borrowed_view.hpp

GetSize

constexpr usize ludus::foundation::BorrowedView< ElementType >::GetSize() const noexcept
Number of borrowed elements, including an invalid extent until the caller validates it.

Related types: usize

Declared in modules/foundation/containers/include/ludus/foundation/containers/borrowed_view.hpp

GetDataOrNull

constexpr ElementType * ludus::foundation::BorrowedView< ElementType >::GetDataOrNull() const noexcept
Borrowed address, possibly null. No ownership transfer or lifetime extension.

Declared in modules/foundation/containers/include/ludus/foundation/containers/borrowed_view.hpp

operator[]

constexpr ElementType & ludus::foundation::BorrowedView< ElementType >::operator[](usize index) const noexcept
Access an element without transferring ownership.

Precondition

IsValid() and index < GetSize(); storage is alive and contains the declared extent.

Related types: usize

Declared in modules/foundation/containers/include/ludus/foundation/containers/borrowed_view.hpp