| 104 | // Find the bit position of the most significant bit (0-based), or -1 if there were no bits set. |
| 105 | template <typename T> |
| 106 | constexpr ssize_t MostSignificantBit(T value) { |
| 107 | static_assert(std::is_integral<T>::value, "T must be integral"); |
| 108 | static_assert(std::is_unsigned<T>::value, "T must be unsigned"); |
| 109 | static_assert(std::numeric_limits<T>::radix == 2, "Unexpected radix!"); |
| 110 | return (value == 0) ? -1 : std::numeric_limits<T>::digits - 1 - CLZ(value); |
| 111 | } |
| 112 | |
| 113 | // Find the bit position of the least significant bit (0-based), or -1 if there were no bits set. |
| 114 | template <typename T> |
no test coverage detected