3#ifndef TETL_BIT_POPCOUNT_HPP
4#define TETL_BIT_POPCOUNT_HPP
18template <etl::builtin_
unsigned_
integer UInt>
19[[nodiscard]]
constexpr auto popcount_fallback(UInt val)
noexcept ->
int
37template <etl::builtin_
unsigned_
integer UInt>
38[[nodiscard]]
constexpr auto popcount(UInt val)
noexcept ->
int
41#if __has_builtin(__builtin_popcount)
42 if constexpr (
sizeof(UInt) ==
sizeof(
unsigned long long)) {
43 return static_cast<int>(__builtin_popcountll(val));
44 }
else if constexpr (
sizeof(UInt) ==
sizeof(
unsigned long)) {
45 return static_cast<int>(__builtin_popcountl(val));
47 return static_cast<int>(__builtin_popcount(val));
52 return etl::detail::popcount_fallback(val);
constexpr auto popcount(UInt val) noexcept -> int
Returns the number of 1 bits in the value of x.
Definition popcount.hpp:38
auto val(pin_number pin) -> etl::uint16_t
Definition gpio.hpp:37
Definition adjacent_find.hpp:8
constexpr auto is_constant_evaluated() noexcept -> bool
Detects whether the function call occurs within a constant-evaluated context. Returns true if the eva...
Definition is_constant_evaluated.hpp:16