C++26 introduces powerful reflection capabilities that enable compile-time JSON parsing and automatic C++ struct generation. The post demonstrates how to use the new reflection API to read JSON files at compile time and create corresponding C++ objects with matching structure and values. Key features include data_member_spec for defining struct members, substitute for template instantiation, and reflect_constant for compile-time value handling. The implementation recursively processes JSON objects, strings, and numbers to generate type-safe C++ structs with external linkage.

10m read timeFrom brevzin.github.io
Post cover image
Table of contents
Let’s Start SimpleFrom One to ManyFull Metal JSONWrapping It Up

Sort: