Files
2025-10-25 03:02:53 +03:00

30 lines
959 B
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[numeric.sat.cast]
# 26 Algorithms library [[algorithms]](./#algorithms)
## 26.10 Generalized numeric operations [[numeric.ops]](numeric.ops#numeric.sat.cast)
### 26.10.17 Saturation arithmetic [[numeric.sat]](numeric.sat#cast)
#### 26.10.17.2 Casting [numeric.sat.cast]
[🔗](#lib:saturate_cast)
`template<class R, class T>
constexpr R saturate_cast(T x) noexcept;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13488)
*Constraints*: R and T are signed or unsigned integer types ([[basic.fundamental]](basic.fundamental "6.9.2Fundamental types"))[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13492)
*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[.](#2.sentence-1)