#templates
3 posts tagged #templates.
One Qt class template can declare typed signals without moc
A Qt engineer named reflect-moc's last open limit as exactly his case: one observable container for many types, which moc cannot give signals. The cause was one line. Now one container template declares typed signals, one generic model serves seven Qt containers, and a random test with six wrong adapters and 31 mutants checks that ghost rows and ghost selections cannot come from it.
The C++20 feature that gave CTRE its interface
Writing ctre::match<"[a-z]+"> requires a string literal to be a template argument, which C++20 allowed and every earlier standard did not. The older spelling still works and still compiles under C++17, so the two sit side by side and show exactly what the feature bought.
std::constant_wrapper carries a compile-time value as an argument
A template parameter is a compile-time value you cannot pass as an argument. A function argument is a runtime value you cannot use as a template parameter. C++26's std::constant_wrapper is an empty object that carries a compile-time value, so it crosses that line: arithmetic on it stays constant, and the result still works as an array extent. GCC 16.1 ships it.