tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
saturate_cast.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2
3#ifndef TETL_NUMERIC_SATURATE_CAST_HPP
4#define TETL_NUMERIC_SATURATE_CAST_HPP
5
10
11namespace etl {
12
17template <builtin_integer To, builtin_integer From>
18[[nodiscard]] constexpr auto saturate_cast(From x) noexcept -> To
19{
22 }
25 }
26 return static_cast<To>(x);
27}
28
29} // namespace etl
30
31#endif // TETL_NUMERIC_SATURATE_CAST_HPP
constexpr auto saturate_cast(From x) noexcept -> To
Converts the value x to a value of type T, clamping x between the minimum and maximum values of type ...
Definition saturate_cast.hpp:18
constexpr auto cmp_greater(T t, U u) noexcept -> bool
Compare the values of two integers t and u. Unlike builtin comparison operators, negative signed inte...
Definition cmp_greater.hpp:20
constexpr auto cmp_less(T t, U u) noexcept -> bool
Compare the values of two integers t and u. Unlike builtin comparison operators, negative signed inte...
Definition cmp_less.hpp:21
Definition adjacent_find.hpp:8
static constexpr auto max() noexcept
Definition numeric_limits.hpp:21
static constexpr auto min() noexcept
Definition numeric_limits.hpp:20