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.
Loading...
Searching...
No Matches
span.h File Reference

POD-safe minimal span for contiguous memory. More...

#include <cstdint>
#include <cstddef>
#include <concepts>
#include <type_traits>
#include <utility>
#include "jh/pods/pod_like.h"
#include "jh/pods/pair.h"

Go to the source code of this file.

Classes

struct  jh::pod::span< T >
 Non-owning typed view over a contiguous memory block. More...

Namespaces

namespace  jh::pod
 Aggregated entry point for Plain-Old-Data and layout-stable value utilities.

Functions

template<typename T, std::uint64_t N>
constexpr span< T > jh::pod::to_span (T(&arr)[N]) noexcept
 Create span from a raw array (T[N]).
template<typename T, std::uint64_t N>
constexpr span< const T > jh::pod::to_span (const T(&arr)[N]) noexcept
 Create span from a const raw array (const T[N]).
template<detail::linear_container C>
constexpr auto jh::pod::to_span (C &c) noexcept
 Creates a POD-compatible span from a linear container.

Detailed Description

POD-safe minimal span for contiguous memory.

Design Goals:

  • Fully POD (T* + uint64_t)
  • No dynamic allocation, no STL dependencies
  • Iteration, slicing, and indexing support
  • Suitable for arena allocators, mmap, and raw containers
Note
Unlike std::span, this type is limited to POD-compatible contiguous memory. It does not support iterator ranges, polymorphic containers, or allocator-aware semantics.
Lifetime of underlying memory must be managed externally.