P4276R1 — A Policy for Scalar Overloads in std::simd
Daniel Towner
LEWG
Revisions R1Sep 2026R0Jul 2026
`std::simd` includes scalar overloads for a few operations, but a proposal should not be expected to provide them simply because other recent papers have. A scalar supplied where a vector is expected is already broadcast to a vector by the converting constructor. An explicit scalar overload is therefore only useful when it offers a concrete semantic or implementation benefit that the broadcast cannot, such as preserving a distinct heterogeneous scalar operation, providing a distinct hardware instruction, or enabling an immediate encoding. This paper proposes a design guideline making that criterion explicit: provide a scalar overload only when there is a demonstrable benefit over broadcasting. We use saturating arithmetic as a worked example of an operation that needs no scalar overload.