26 Algorithms library [algorithms]

26.10 Generalized numeric operations [numeric.ops]

26.10.17 Saturation arithmetic [numeric.sat]

26.10.17.2 Casting [numeric.sat.cast]

template<class R, class T> constexpr R saturate_cast(T x) noexcept;
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.

Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant