tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
test_bit.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2
3#ifndef TETL_BIT_TEST_BIT_HPP
4#define TETL_BIT_TEST_BIT_HPP
5
10
11namespace etl {
12
18template <etl::builtin_unsigned_integer UInt>
19[[nodiscard]] constexpr auto test_bit(UInt word, UInt pos) noexcept -> bool
20{
22 return static_cast<UInt>(word & static_cast<UInt>(UInt(1) << pos)) != UInt(0);
23}
24
29template <etl::size_t Pos, etl::builtin_unsigned_integer UInt>
30[[nodiscard]] constexpr auto test_bit(UInt word) noexcept -> bool
31{
32 static_assert(Pos < etl::numeric_limits<UInt>::digits);
33 return etl::test_bit(word, static_cast<UInt>(Pos));
34}
35
36} // namespace etl
37
38#endif // TETL_BIT_TEST_BIT_HPP
#define TETL_PRECONDITION(...)
Definition check.hpp:16
constexpr auto test_bit(UInt word, UInt pos) noexcept -> bool
Test bit at position pos.
Definition test_bit.hpp:19
Definition adjacent_find.hpp:8
static constexpr int digits
Definition numeric_limits.hpp:24