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
bytes_view.h File Reference

POD-safe minimal byte-range view with reinterpreting and cloning utilities. More...

#include <cstddef>
#include <cstdint>
#include <memory>
#include <new>
#include <cstring>
#include "jh/pods/pod_like.h"
#include "jh/metax/hash.h"

Go to the source code of this file.

Classes

struct  jh::pod::bytes_view
 A read-only view over a block of raw bytes. More...

Namespaces

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

Concepts

concept  jh::pod::trivial_bytes
 Concept for trivially layout-compatible types (POD-compatible memory view).

Detailed Description

POD-safe minimal byte-range view with reinterpreting and cloning utilities.

This header defines jh::pod::bytes_view — a low-level, read-only, non-owning abstraction over raw memory regions. It enables safe reinterpretation and controlled cloning of memory blocks into POD-compatible types.

Design Goals:

  • Fully POD (const std::byte* + uint64_t)
  • No ownership, no destructor, no STL containers
  • Support for reinterpretation (at, fetch)
  • Stack-safe and heap-safe cloning (clone)
  • Works seamlessly with pod_like and trivial_bytes types
Note
This type assumes the data lifetime is externally guaranteed. It is ideal for parsing binary payloads, memory-mapped blobs, protocol headers, or arena-based serialization systems.