30 lines
959 B
Markdown
30 lines
959 B
Markdown
[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.2 Fundamental 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)
|