P2956R2 — Add saturating library support to std::simd
Daniel Towner, Ruslan Arutyunyan
LWG
Revisions R3Jul 2026R2Apr 2026
The Working Draft of C++26 includes data parallel types. It mostly provides operators which work on or with `std::simd` types, but it also includes overloads of useful functions from other parts of C++ (e.g., sin, cos, abs). In [P0543R3] a proposal was made to provide saturating operation support for some basic arithmetic operations and casts. In particular, `saturating_add`, `saturating_sub`, `saturating_mul` and `saturating_div` are provided. These perform saturating arithmetic operations which are effectively performed in infinite precision, and will return the smallest or largest value when it is too large to be represented in that type. In addition, `saturating_cast` is also provided to convert to a new type, and to saturate to the range of that type if required.