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::runtime_arr_helper::bool_flat_alloc Struct Referencefinal

Flat allocator for bool — disables bit-packing in jh::runtime_arr<bool>. More...

#include <jh/core/runtime_arr.h>

Classes

struct  rebind

Public Types

using value_type = bool

Public Member Functions

bool * allocate (std::size_t n)
void deallocate (bool *p, std::size_t) noexcept
bool operator== (const bool_flat_alloc &) const noexcept=default

Detailed Description

Flat allocator for bool — disables bit-packing in jh::runtime_arr<bool>.

Overview

bool_flat_alloc provides a minimal, stateless allocator used to instantiate jh::runtime_arr<bool, bool_flat_alloc> as a byte-based (non-packed) boolean array.

Normally, jh::runtime_arr<bool> uses a bit-packed storage model, compressing 8 boolean values into a single byte (64 per 64-bit word). By supplying this allocator, each bool instead occupies 1 full byte, allowing direct memory access and STL-contiguous semantics.

Usage

// Compact, bit-packed (default)
// Byte-based, non-packed
plain[0] = true;
A move-only, fixed-capacity array with runtime-determined length and RAII-based ownership.
Definition runtime_arr.h:367

Behavior

  • Stateless — all methods are static.
  • Allocates raw bool[n] arrays via new[].
  • Deallocates via delete[].
  • Serves as the byte-based alternative allocator for testing or explicit non-packed use cases.
  • Does not implement std::allocator_traits and is not STL-compatible.

Typical Use Case

Used for performance benchmarking and correctness testing of the jh::runtime_arr<bool> specialization, or for scenarios where bit-packing overhead is undesirable (e.g. frequent random access or interop with APIs expecting bool* pointers).

See also

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