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

Macro-based POD helper utilities. More...

#include "pod_like.h"
#include "jh/typing/monostate.h"

Go to the source code of this file.

Macros

#define JH_POD_STRUCT(NAME, ...)
 Declares a strict POD struct with operator== and enforces POD constraints at compile time.
#define JH_ASSERT_POD_LIKE(TYPE)
 Compile-time assertion to ensure a type is POD-like, according to jh::pod::pod_like.

Detailed Description

Macro-based POD helper utilities.

This header provides compile-time helper macros for defining and validating POD-compatible structures. It no longer includes transitional tuple utilities.

Contents

  • JH_POD_STRUCT โ€” Declare a POD struct with operator== and automatic pod_like validation.
  • JH_ASSERT_POD_LIKE โ€” Verify a manually defined type satisfies jh::pod::pod_like constraints.

Version Notes

  • From 1.3.4 onward, tools.h only contains macro-based helpers.
  • The transitional jh::pod::tuple (available in 1.3.0-1.3.3) was removed and replaced with a full implementation in <jh/pods/tuple.h>.
See also
jh::pod::tuple (in jh/pods/tuple.h)
jh::pod::pod_like

Macro Definition Documentation

◆ JH_ASSERT_POD_LIKE

#define JH_ASSERT_POD_LIKE ( TYPE)
Value:
static_assert(::jh::pod::pod_like<TYPE>, \
#TYPE " must satisfy jh::pod_like: trivial, standard layout, POD-compatible type.")

Compile-time assertion to ensure a type is POD-like, according to jh::pod::pod_like.

Use this macro if you're writing your own struct (not using JH_POD_STRUCT) but still want to ensure compatibility with POD-only containers (like pod_stack).

Example:

struct MyManualPod {
int x;
float y;
};
JH_ASSERT_POD_LIKE(MyManualPod);
#define JH_ASSERT_POD_LIKE(TYPE)
Compile-time assertion to ensure a type is POD-like, according to jh::pod::pod_like.
Definition tools.h:118

Guarantees:

This will emit a compile-time error if the type is not:

  • trivially copyable
  • trivially constructible/destructible
  • standard layout

◆ JH_POD_STRUCT

#define JH_POD_STRUCT ( NAME,
... )
Value:
struct NAME { \
__VA_ARGS__ \
constexpr bool operator==(const NAME&) const = default; \
}; \
static_assert(::jh::pod::pod_like<NAME>, \
#NAME " must be trivially copyable, " \
"standard layout, and contain only POD-compatible members.")

Declares a strict POD struct with operator== and enforces POD constraints at compile time.

Parameters
NAMEThe name of the struct to define.
...The member declarations of the struct.

Example:

int x;
int y;
);
#define JH_POD_STRUCT(NAME,...)
Declares a strict POD struct with operator== and enforces POD constraints at compile time.
Definition tools.h:83

Guarantees:

  • The struct is treated as a pod_like type.
  • operator== is auto-generated (= default).
  • If the type violates POD requirements (e.g., contains std::string or unique_ptr), it triggers a compile-time error.