Behold the power of meta::substitute
This title could be clearer and more informative.Try out Clickbait Shieldfor free (5 uses left this month).
A deep dive into C++26 reflection capabilities, specifically `std::meta::substitute` and `std::meta::extract`, showing how to parse format strings entirely at compile time without function templates. The technique uses a `consteval` constructor to capture a string literal as a constant, then uses `substitute` to instantiate templates from runtime-like `meta::info` values, and `extract` to pull typed values back out. The result is a `highlight_print` function that parses a format string at compile time and generates the correct formatting function — all using regular functions instead of function templates. The post also compares this approach to Zig's `comptime` parameters and `comptime var`, suggesting two language features that could simplify C++ metaprogramming significantly.
Table of contents
consteval ConstructorsThe End GoalFunctions, not Function TemplatesPromoting to Static StorageParsing an InterpolationThe Rest of the OwlConclusionSort: