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
jh::pod::bitflags< N > Struct Template Referencefinal

POD-compatible fixed-size bitflags structure.Generic fallback specialization for non-native sizes (e.g. 24, 120 bits, etc). More...

#include <jh/pods/bits.h>

Inheritance diagram for jh::pod::bitflags< N >:

Detailed Description

template<std::uint16_t N>
requires (N % 8 == 0 && N <= 8 * max_pod_bitflags_bytes)
struct jh::pod::bitflags< N >

POD-compatible fixed-size bitflags structure.Generic fallback specialization for non-native sizes (e.g. 24, 120 bits, etc).

Template Parameters
NNumber of bits. Must be divisible by 8 and ≤ 32'768.

Storage strategy:

  • N = 8,16,32,64 → backed by a native unsigned integer
  • Other valid multiples of 8 → backed by a fixed-size byte array (little-endian)

Properties:

  • All operations are constexpr-compatible and noexcept
  • .set(), .clear(), .flip(), .has() are unchecked
  • Bitwise operators (|, &, ^, ~) supported
  • .count() returns the number of bits set
  • .set_all() / .reset_all() / .flip_all() available
  • .bits member (native) or .data (byte-array)

Design Constraints:

  • Fully inline layout, no heap or dynamic allocation
  • Cannot exceed 4KB total memory usage
  • No virtual functions, no RTTI, trivially copyable
Note
This is a POD type. Suitable for:
  • Memory-mapped files or sockets
  • std::memcpy or binary serialization
  • constexpr and static_assert contexts
Warning
This structure is low-level. All operations assume caller correctness.

The documentation for this struct was generated from the following file: