P3844R3 — Restore simd::vec broadcast from int
Matthias Kretz
LWG
Revisions R4Feb 2026R3Feb 2026
Since we don’t have `constexpr` function arguments in the language, `std::simd` works around it by recognizing `integral-constant-like` / `constant-wrapper-like` types, that encode a *value* into a type. This, however, comes at a compile-time cost. Every different value leads to a template specialization of both `constant_wrapper` and a `basic_vec` broadcast constructor (with it’s helper types/concepts to determine whether the specialization is allowed). Consequently, for `vec<float>`, I would recommend to always use an `f` suffix rather than `std::cw`. But that solution is fairly limited, since we don’t have literals for 8-bit and 16-bit integers in the language. A function template like `template` `<``simd_integral` `V``>` `V` `f``(``V` `x``)` `{` `return` `x` `+` `1;` `//` `ill -formed` `for` `V:: value_type` `=` `(u)int8_t ,` `(un)int16_t ,` `and` `uint32_t` `}` needs to use `x` `+` `V(1)`1. A clever user might write `x` `+` `'\1'` instead. But that fails for the `char` type with different signedness. Consequently, users would need to get used to writing explicit conversions for the constants they use in `std::simd` code. That’s not only verbose and ugly, it is also error-prone