@@ -491,10 +491,12 @@ error_code deserialize(auto& json_value, T& out) {
491491 simdjson::ondemand::object obj;
492492 auto er = json_value.get_object().get(obj);
493493 if(er) { return er; }
494+ // capture the attributes:
495+ constexpr auto members = std::define_static_array(std::meta::nonstatic_data_members_of(^^T,
496+ std::meta::access_context::unchecked()));
494497
495- // This [:expand:] happens at COMPILE TIME
496- // It literally generates code for each member
497- [:expand(std::meta::nonstatic_data_members_of(^^T)):] >> [&]<auto member>() {
498+ // This for loop happens at COMPILE TIME
499+ template for (constexpr auto member : members) {
498500 // These are compile-time constants
499501 constexpr std::string_view field_name = std::meta::identifier_of(member);
500502 constexpr auto member_type = std::meta::type_of(member);
@@ -512,13 +514,14 @@ error_code deserialize(auto& json_value, T& out) {
512514
513515---
514516
515- # The [ :expand:] Statement
517+
518+ # The template for Statement
516519
517- The ` [:expand:] ` statement is the key:
520+ The ` template for ` statement is the key:
518521
519522- It's like a ** compile-time for-loop**
520- - Generates code for each struct member
521- - By the time your program runs, all reflection has been " expanded" into normal C++ code
523+ - E.g., it generates code for each struct member
524+ - By the time your program runs, all reflection has been * expanded* into normal C++ code
522525
523526This means:
524527- ** Zero runtime overhead**
0 commit comments