tetl
0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
ilog2.hpp
Go to the documentation of this file.
1
// SPDX-License-Identifier: BSL-1.0
2
3
#ifndef TETL_MATH_ILOG2_HPP
4
#define TETL_MATH_ILOG2_HPP
5
6
#include <
etl/_concepts/integral.hpp
>
7
8
namespace
etl
{
9
10
template
<
int
egral Int>
11
[[nodiscard]]
constexpr
auto
ilog2
(Int x)
noexcept
-> Int
12
{
13
auto
result = Int(0);
14
for
(; x > Int(1); x >>= Int(1)) {
15
++result;
16
}
17
return
result;
18
}
19
20
}
// namespace etl
21
22
#endif
// TETL_MATH_ILOG2_HPP
integral.hpp
etl
Definition
adjacent_find.hpp:8
etl::ilog2
constexpr auto ilog2(Int x) noexcept -> Int
Definition
ilog2.hpp:11
include
etl
_math
ilog2.hpp
Generated on Sat Mar 8 2025 16:19:59 for tetl by
1.14.0