A runnable, example-driven walkthrough of C++26 static reflection (P2996 and friends), built on a pinned bloomberg/clang-p2996 Docker image.
Every post has working code you can compile and run in under a minute. Every example is also mirrored on Compiler Explorer so you can play without installing anything.
Each post's examples/godbolt.md lists permalinks. Click, edit, share.
Requires Docker (or Colima/OrbStack on macOS). Build once, then use the wrappers.
./build.sh # 30-60 min, one-time; arm64-native
./cpp hello_reflection.cpp -o hello # compile with clang-p2996
./run ./hello # run inside the containerToolchain: pinned to bloomberg/clang-p2996@9ffb96e3ce36. The Dockerfile builds LLVM for AArch64 only with minimal components to keep build time and image size reasonable.
All examples compile with:
clang++ -std=c++26 -freflection -stdlib=libc++ ...
which is what ./cpp wraps.
Status legend: ⬜ planned · 🚧 drafting · ✅ published
| # | Post | Audience | Status |
|---|---|---|---|
| 1 | Why C++26 reflection matters | Polyglot | ⬜ |
| 2 | Your first ^^: reflecting types, walking members |
Mixed | ⬜ |
| 3 | Splicing: [: r :] and round-tripping reflections |
Working C++ | ⬜ |
| 4 | template for: iterating reflections at compile time |
Working C++ | ⬜ |
| # | Post | Audience | Status |
|---|---|---|---|
| 5 | Goodbye magic_enum: enum reflection done right |
Working C++ | ⬜ |
| 6 | Auto-generating std::formatter<T> for any aggregate |
Working C++ | ⬜ |
| 7 | Deriving equality, hashing, and ordering from structure | Working C++ | ⬜ |
| # | Post | Audience | Status |
|---|---|---|---|
| 8 | A 40-line JSON serializer with reflection | Working C++ | ⬜ |
| 9 | Annotations: tag-driven serialization in C++ | Working C++ | ⬜ |
| 10 | Deserialization and std::expected error paths |
Working C++ | ⬜ |
| 11 | One codegen, many wire formats: YAML, TOML, MessagePack | Working C++ | ⬜ |
| # | Post | Audience | Status |
|---|---|---|---|
| 12 | CLI parsing: struct → typed command-line parser | Working C++ | ⬜ |
| 13 | A tiny ORM: struct → SQL | Working C++ | ⬜ |
| 14 | Autowired dependency injection | Working C++ | ⬜ |
| 15 | Auto-generated mocks from interfaces | Working C++ | ⬜ |
| # | Post | Audience | Status |
|---|---|---|---|
| 16 | define_aggregate: synthesizing types at compile time |
Working C++ | ⬜ |
| 17 | Replacing Qt's MOC with reflection | Working C++ | ⬜ |
| 18 | Capstone: C++26 reflection vs Rust, C#, Java, TS, Go, Python | Polyglot | ⬜ |
- Star the repo; each published post ships as a tagged release (
post-01,post-02, ...). - Every post links to a GitHub Discussion thread — that's where questions and corrections live.
- Issues are reserved for bugs in example code or the Docker toolchain.
- The Bloomberg fork is explicitly not production-ready per its own README. Use it to learn and experiment with P2996, not to ship.
- The pinned SHA will bump periodically as P2996 evolves. Old posts link to specific SHAs so historical examples always compile.
- Annotations (P3394) syntax may change; posts that depend on annotations name the exact SHA they were verified against.
./verify.sh walks every post's examples/ directory, compiles + runs each sample, and prints pass/fail. Required before tagging a release.
Code examples: MIT. Prose: CC BY 4.0.