|
JH-Toolkit v1.4.1
An engineering-oriented C++20 toolkit with duck-typed concepts, static design, async coroutines, and semantic containers — header-only, RTTI-free, and concurrency-friendly.
|
Non-owning typed view over a contiguous memory block. More...
#include <jh/pods/span.h>
Public Types | |
| using | element_type = T |
Element type (alias of T). | |
| using | value_type = std::remove_cv_t<T> |
| Value type without const/volatile. | |
| using | size_type = std::uint64_t |
| Size type (64-bit). | |
| using | difference_type = std::ptrdiff_t |
| Signed difference type. | |
| using | reference = value_type & |
| Reference to element. | |
| using | const_reference = const value_type & |
| Const reference to element. | |
| using | pointer = value_type * |
| Pointer to element. | |
| using | const_pointer = const value_type * |
| Const pointer to element. | |
Public Member Functions | |
| constexpr const_reference | operator[] (std::uint64_t index) const noexcept |
| Access an element by index (no bounds check). | |
| constexpr const_pointer | begin () const noexcept |
| Pointer to the first element. | |
| constexpr const_pointer | end () const noexcept |
| Pointer to one-past-the-end. | |
| constexpr size_type | size () const noexcept |
| Number of elements in view. | |
| constexpr bool | empty () const noexcept |
| Whether the view is empty. | |
| constexpr span | sub (const std::uint64_t offset, const std::uint64_t count=0) const noexcept |
Creates a sub-span from offset, with optional count elements. | |
| constexpr span | first (const std::uint64_t count) const noexcept |
Returns the first count elements as a new span. | |
| constexpr span | last (const std::uint64_t count) const noexcept |
Returns the last count elements as a new span. | |
| constexpr bool | operator== (const span &rhs) const =default |
| Equality comparison between two spans. | |
Public Attributes | |
| T * | data |
| Pointer to the first element. | |
| std::uint64_t | len |
| Number of elements. | |
Non-owning typed view over a contiguous memory block.
Behaves like a stripped-down std::span, but remains fully POD (T* + uint64_t).
.at() | T | Element type. Must satisfy pod_like. |
|
constexprdefault |
Equality comparison between two spans.
Two spans are considered equal if they reference the same sequence object (i.e. identical pointer and identical length). This does not compare the element values.
= default, which checks data and len. If you need value-wise comparison, use algorithms such as std::equal(lhs.begin(), lhs.end(), rhs.begin()).
|
inlinenodiscardconstexprnoexcept |
Creates a sub-span from offset, with optional count elements.
If count == 0 (default), the view extends to end. If offset > len, returns empty span.