|
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.
|
Aggregated entry point for Plain-Old-Data and layout-stable value utilities. More...
Namespaces | |
| namespace | literals |
Official literal helpers for jh::pod types. | |
Classes | |
| struct | array |
POD-compatible fixed-size array, similar in shape to std::array, but simpler and fully POD. More... | |
| struct | bitflags |
| POD-compatible fixed-size bitflags structure.Generic fallback specialization for non-native sizes (e.g. 24, 120 bits, etc). More... | |
| struct | bitflags< 8 > |
| Specialization for 8-bit bitflags. More... | |
| struct | bitflags< 16 > |
| Specialization for 16-bit bitflags. More... | |
| struct | bitflags< 32 > |
| Specialization for 32-bit bitflags. More... | |
| struct | bitflags< 64 > |
| Specialization for 64-bit bitflags. More... | |
| struct | bytes_view |
| A read-only view over a block of raw bytes. More... | |
| struct | optional |
| POD-compatible optional wrapper. More... | |
| struct | pair |
| POD-compatible aggregate of two values, equivalent in layout to a plain struct. More... | |
| struct | span |
| Non-owning typed view over a contiguous memory block. More... | |
| struct | string_view |
| Read-only string view with POD layout. More... | |
| struct | tuple |
| POD-compatible tuple type supporting structured bindings and tuple-like utilities. More... | |
Concepts | |
| concept | std_uint |
| Internal constraint for native unsigned integer types. | |
| concept | trivial_bytes |
| Concept for trivially layout-compatible types (POD-compatible memory view). | |
| concept | pod_like |
| Concept for types that are safe to treat as plain old data (POD). | |
| concept | cv_free_pod_like |
Concept for POD-like types that are free of const or volatile qualification. | |
| concept | streamable |
Checks whether a type can be streamed to std::ostream. | |
| concept | streamable_pod |
Debug-only constraint for POD-like types printable to std::ostream. | |
Functions | |
| template<std_uint UInt> | |
| constexpr auto | uint_to_bytes (const UInt val) |
| Convert an unsigned integer into a little-endian byte array. | |
| template<std::uint16_t N> | |
| constexpr auto | bytes_to_uint (const array< std::uint8_t, N > &arr) |
| Convert a little-endian byte array into an unsigned integer. | |
| template<std::uint16_t N> | |
| constexpr bitflags< N > | operator| (const bitflags< N > &lhs, const bitflags< N > &rhs) noexcept |
| template<std::uint16_t N> | |
| constexpr bitflags< N > | operator& (const bitflags< N > &lhs, const bitflags< N > &rhs) noexcept |
| template<std::uint16_t N> | |
| constexpr bitflags< N > | operator^ (const bitflags< N > &lhs, const bitflags< N > &rhs) noexcept |
| template<std::uint16_t N> | |
| constexpr bitflags< N > | operator~ (const bitflags< N > &v) noexcept |
| template<std::uint16_t N> | |
| constexpr array< std::uint8_t, N/8 > | to_bytes (bitflags< N > f) |
Serialize a bitflags<N> into a little-endian byte array (snapshot). | |
| template<std::uint16_t N> | |
| constexpr bitflags< N > | from_bytes (array< std::uint8_t, N/8 > arr) |
Deserialize a bitflags<N> from a byte array (snapshot). | |
| template<pod_like T> | |
| constexpr optional< T > | make_optional (const T &value) noexcept |
Construct an optional<T> with a value. | |
| template<cv_free_pod_like T1, cv_free_pod_like T2> | |
| constexpr auto | make_pair (T1 first, T2 second) noexcept |
| Constructs a POD-compatible pair from two values. | |
| template<typename T, std::uint64_t N> | |
| constexpr span< T > | 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 > | to_span (const T(&arr)[N]) noexcept |
Create span from a const raw array (const T[N]). | |
| template<detail::linear_container C> | |
| constexpr auto | to_span (C &c) noexcept |
Creates a POD-compatible span from a linear container. | |
| template<streamable T, std::uint16_t N> | |
| std::ostream & | operator<< (std::ostream &os, const jh::pod::array< T, N > &arr) |
| template<std::uint16_t N> | |
| std::ostream & | operator<< (std::ostream &os, const jh::pod::array< char, N > &str) |
| std::ostream & | operator<< (std::ostream &os, jh::typed::monostate &) |
| template<streamable T1, streamable T2> | |
| std::ostream & | operator<< (std::ostream &os, const jh::pod::pair< T1, T2 > &t) |
| template<streamable T> | |
| std::ostream & | operator<< (std::ostream &os, const jh::pod::optional< T > &opt) |
| template<std::uint16_t N> | |
| std::ostream & | operator<< (std::ostream &os, const jh::pod::bitflags< N > &flags) |
| std::ostream & | operator<< (std::ostream &os, const jh::pod::bytes_view bv) |
| template<streamable T> | |
| std::ostream & | operator<< (std::ostream &os, const span< T > &sp) |
| std::ostream & | operator<< (std::ostream &os, const string_view &sv) |
| template<streamable_pod Pod> | |
| std::string | to_string (const Pod &p) |
| template<streamable... Ts> | |
| std::ostream & | operator<< (std::ostream &os, const jh::pod::tuple< Ts... > &t) |
| template<std::size_t I, typename... Ts> | |
| constexpr decltype(auto) | get (tuple< Ts... > &t) noexcept |
| template<std::size_t I, typename... Ts> | |
| constexpr auto | get (const tuple< Ts... > &t) noexcept |
| template<std::size_t I, typename T1, typename T2> | |
| constexpr decltype(auto) | get (jh::pod::pair< T1, T2 > &p) noexcept |
| template<std::size_t I, typename T1, typename T2> | |
| constexpr decltype(auto) | get (const jh::pod::pair< T1, T2 > &p) noexcept |
| template<std::size_t I, typename T, std::uint16_t N> | |
| constexpr decltype(auto) | get (jh::pod::array< T, N > &a) noexcept |
| template<std::size_t I, typename T, std::uint16_t N> | |
| constexpr decltype(auto) | get (const jh::pod::array< T, N > &a) noexcept |
| template<typename... Ts> | |
| constexpr auto | make_tuple (Ts &&... args) noexcept |
| Constructs a POD-compatible tuple from given arguments. | |
| template<typename... Ts> | |
| constexpr bool | operator== (const tuple< Ts... > &lhs, const tuple< Ts... > &rhs) noexcept |
| template<typename... Ts> | |
| constexpr bool | operator!= (const tuple< Ts... > &lhs, const tuple< Ts... > &rhs) noexcept |
Aggregated entry point for Plain-Old-Data and layout-stable value utilities.
The <jh/pod> forwarding header provides a unified, low-level interface over the POD-oriented components implemented under jh/pods/.
This module defines a collection of layout-deterministic, trivially copyable value types designed for binary safety, predictable memory representation, and zero-overhead abstraction.
All types and utilities exposed through jh::pod are defined in terms of the jh::pod::pod_like contract, ensuring standard layout, trivial lifetime semantics, and safe use in serialization, memory mapping, and low-level data transport.
|
nodiscardconstexpr |
Convert a little-endian byte array into an unsigned integer.
| N | Byte count. |
| arr | Input array. |
|
constexpr |
Deserialize a bitflags<N> from a byte array (snapshot).
|
nodiscardconstexprnoexcept |
Construct an optional<T> with a value.
| value | Value to copy into optional. |
optional<T> with .has() == true.
|
constexprnoexcept |
Constructs a POD-compatible pair from two values.
This function aligns with std::make_pair for interface consistency. It performs no special handling beyond aggregate initialization and exists solely to provide a familiar, STL-compatible API name.
| T1 | Type of the first element. |
| T2 | Type of the second element. |
| first | First element value. |
| second | Second element value. |
jh::pod::pair<T1, T2> containing the given elements.
|
constexprnoexcept |
Constructs a POD-compatible tuple from given arguments.
This is the general-purpose tuple construction interface aligned with std::make_tuple, but restricted to POD-compatible types. Each element is assigned by index, ensuring consistent aggregate initialization semantics across compilers.
jh::pod::tuple jh::pod::array<T, N> or jh::pod::array<char, N> when constructing tuples.| Ts | Variadic list of POD-compatible argument types. |
| args | The values to store in the tuple. |
jh::pod::tuple containing the given values.
|
nodiscardconstexpr |
Serialize a bitflags<N> into a little-endian byte array (snapshot).
|
nodiscardconstexprnoexcept |
Creates a POD-compatible span from a linear container.
This function constructs a span<T> that references the contiguous data region of a container C. The access method (field, member function, or ADL helper) is determined at compile time according to the precomputed linear_status<C>.
Accessor detection follows a fixed precedence:
ADL (get_data(), get_size()) → field (data, len) → member function (data(), size()).
This allows users to explicitly provide ADL overloads to override internal members when the container layout is not standard or may be misleading.
data and data() are mutually exclusive — defining both is undefined behavior. len and size() may coexist, but they are expected to report identical lengths. my_ns::get_size(my_ns::MyContainer) or get_data() via ADL to override detection. span{ptr, len} instead. Returns a non-owning span<Elem> referencing the same contiguous memory as the source container.
|
nodiscardconstexpr |
Convert an unsigned integer into a little-endian byte array.
| UInt | Must be one of: uint8_t, uint16_t, uint32_t, uint64_t. |
| val | The input value to encode. |
array<uint8_t, sizeof(UInt)> encoded in little-endian order.