27 Algorithms library [algorithms]

27.10 Generalized numeric operations [numeric.ops]

27.10.17 Saturation arithmetic [numeric.sat] Casting [numeric.sat.cast]

template<class R, class T> constexpr R saturate_cast(T x) noexcept;
Constraints: R and T are signed or unsigned integer types ([basic.fundamental]).
Returns: If x is representable as a value of type R, x; otherwise, either the largest or smallest representable value of type R, whichever is closer to the value of x.