tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
in_range.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2
3#ifndef TETL_UTILITY_IN_RANGE_HPP
4#define TETL_UTILITY_IN_RANGE_HPP
5
10
11namespace etl {
12
19template <builtin_integer R, builtin_integer T>
20[[nodiscard]] constexpr auto in_range(T t) noexcept -> bool
21{
22 using limits = etl::numeric_limits<R>;
23 return etl::cmp_greater_equal(t, limits::min()) and etl::cmp_less_equal(t, limits::max());
24}
25
26} // namespace etl
27
28#endif // TETL_UTILITY_IN_RANGE_HPP
constexpr auto in_range(T t) noexcept -> bool
Returns true if the value of t is in the range of values that can be represented in R,...
Definition in_range.hpp:20
constexpr auto cmp_greater_equal(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_equal.hpp:20
constexpr auto cmp_less_equal(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_equal.hpp:20
Definition adjacent_find.hpp:8
Definition numeric_limits.hpp:17