Provides constexpr bit counting functions. More...
#include <cstdint>#include <type_traits>#include <utility>#include "ugmisc/features.hpp"#include "ugmisc/sfinae_helpers.hpp"Go to the source code of this file.
Functions | |
| template<class T> | |
| constexpr bitwise_uint_only< T > | ugmisc::clz (T) noexcept |
| template<class T> | |
| constexpr bitwise_uint_only< T > | ugmisc::cl1 (T) noexcept |
| template<class T> | |
| constexpr bitwise_uint_only< T > | ugmisc::crz (T) noexcept |
| template<class T> | |
| constexpr bitwise_uint_only< T > | ugmisc::cr1 (T) noexcept |
| template<class T> | |
| constexpr bitwise_uint_only< T > | ugmisc::bitwidth (T) noexcept |
Provides constexpr bit counting functions.
If features.hpp claims that we have the std library bit counting functions, we use those.
If not we use a series of bitwise logic ops to home in on the place where the first set bit is, or last set bit or whatever.
TBD: Should the clz function and its relatives be renamed to match the standard functions' names? Probably.
|
constexprnoexcept |
Counts bits needed to represent the value. Simply forwards to std::bit_width if that is available, or provides its own implementation otherwise.
|
constexprnoexcept |
Counts left one bits. Simply forwards the call to std::countl_one if that is available, or provides its own implementation otherwise.
|
constexprnoexcept |
Counts left zero bits. Simply forwards the call to std::countl_zero if that is available, or provides its own implementation otherwise.
|
constexprnoexcept |
Counts right one bits. Simply forwards the call to std::countr_one if that is available, or provides its own implementation otherwise.
|
constexprnoexcept |
Counts right zero bits. Simply forwards the call to std::countr_zero if that is available, or provides its own implementation otherwise.