C++26 Reflection: A Value-Based vs. Type-Based Comparison

2025-06-12

This article compares the value-based and type-based reflection models in C++26 by tackling a problem solvable only with reflection: implementing an `is_structural` type trait. The author demonstrates how much simpler and more readable the value-based approach is compared to the type-based approach, which requires significantly more template metaprogramming. Differences in handling recursion and guarding instantiations are also discussed, concluding that while C++26 introduces new syntax, the value-based model streamlines reflection programming, resulting in more understandable and maintainable code.

Read more
Development

C++26 Reflection: Building a High-Performance Struct-of-Arrays Vector

2025-05-09

This article demonstrates how to leverage C++26 reflection to implement a high-performance struct-of-arrays vector (SoaVector). By storing struct members in separate arrays, SoaVector avoids memory waste and improves access efficiency. The article details the implementation of SoaVector, including memory management, element addition, reading, and referencing. A comparison with a similar Zig implementation highlights the power and potential of C++26 reflection.

Read more
Development Struct-of-Arrays

C++ Ranges: Performance Bottlenecks and Optimization Strategies

2025-04-08

This article delves into performance issues with C++ Ranges adaptors like `views::filter` and `views::take_while`. These adaptors introduce redundant iterator comparisons, impacting efficiency. The author analyzes the root causes and proposes two solutions: using Tristan Brindle's Flux library, which enhances performance through internal iteration and improved memory management; and a more radical approach leveraging potential C++ token sequence features to generate optimal loop code, bypassing Ranges limitations. Both solutions significantly improve efficiency, especially for complex range operations involving `views::reverse`.

Read more
Development