You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
constexpr auto member_type = std::meta::type_of(member);
405
+
406
+
// This generates code for each member
407
+
obj[field_name].get(out.[:member:]);
424
408
}
425
409
```
426
410
427
-
---
428
-
429
-
430
-
# The template for Statement
431
-
432
-
The `template for` statement is the key:
433
-
434
-
- It's like a **compile-time for-loop**
435
-
- E.g., it generates code for each struct member
436
-
- By the time your program runs, all reflection has been *expanded* into normal C++ code
437
-
438
-
This means:
439
-
-**Zero runtime overhead**
440
-
-**Full optimization opportunities**
441
-
-**Type safety at compile time**
411
+
See full implementation on [GitHub](https://github.com/simdjson/simdjson/blob/8aae14931d4f3cb0ef529ba5f7e2e34d7bcc8e19/include/simdjson/generic/ondemand/std_deserialize.h#L290)
442
412
443
413
---
444
414
@@ -462,36 +432,6 @@ Player p = simdjson::from<Player>(json);
462
432
// Runtime values flow through compile-time generated code
463
433
```
464
434
465
-
---
466
-
467
-
# Zero Overhead: Why It's Fast
468
-
469
-
Since reflection happens at compile time, there's no runtime penalty:
470
-
471
-
1. **No runtime type inspection** - everything is known at compile time
472
-
2. **No string comparisons for field names** - they become compile-time constants
473
-
3. **Optimal code generation** - the compiler sees the full picture
474
-
4. **Inline everything** - generated code can be fully optimized
475
-
476
-
The generated code is often **faster than hand-written code** because:
477
-
- It's consistently optimized
478
-
- No human errors or inefficiencies
479
-
- Leverages simdjson's SIMD parsing throughout
480
-
481
-
---
482
-
483
-
# Performance: The Best Part
484
-
485
-
You might think "automatic = slow", but with simdjson + reflection:
486
-
487
-
- **Compile-time code generation**: No runtime overhead from reflection
488
-
- **SIMD-accelerated parsing**: simdjson uses CPU vector instructions
489
-
- **Zero allocation**: String views and in-place parsing
490
-
- **Throughput**: ~2-4 GB/s on modern hardware
491
-
492
-
The generated code is often *faster* than hand-written code!
0 commit comments