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
;
1
#
Constraints
:
R
and
T
are signed or unsigned integer types (
[basic.
fundamental]
)
.
2
#
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
.