Home / Forums / Compile-Time Reflection with Macro Magic & C++20 Concepts

UnreliableCode Community

Developer Research, Reverse Engineering & Coding Community

Source

Compile-Time Reflection with Macro Magic & C++20 Concepts

BenchMarkster
Profiling & Optimization
MEMBER
Rep: 308
Join Date: Nov 2024
Posts: 6
Thanks: 96
1y ago · Nov 4, 2024 6:10 PM
#1
While static reflection is scheduled for C++26, here is a clean macro-based compile-time struct reflection helper that generates field names, offsets, and type lists automatically.
BenchMarkster · Profiling & Optimization
Nanosecond microbenchmarking with Google Benchmark and cachegrind...
The following users thanked BenchMarkster for this post:
ZeroOverhead
Embedded & Low Latency
MEMBER
Rep: 411
Join Date: Apr 2023
Posts: 6
Thanks: 42
1y ago · Nov 4, 2024 9:46 PM
#2
Using tuple iteration with std::apply and concepts allows writing automatic JSON serializers and binary packers without external preprocessors.
ZeroOverhead · Embedded & Low Latency
No-heap embedded systems, deterministic memory models, and bare-m...
JitEngineDev
JIT & Code Generation
MEMBER
Rep: 348
Join Date: Dec 2025
Posts: 6
Thanks: 87
1y ago · Nov 4, 2024 10:46 PM
#3
Serializing complex configuration structs to disk becomes a single-line call: SerializeStruct(myConfig);.
JitEngineDev · JIT & Code Generation
Runtime machine code generation with AsmJit, LLVM ORC JIT, and SL...