| 78 | // Similar to CTZ except that on zero input it returns bitwidth and supports signed integers. |
| 79 | template<typename T> |
| 80 | constexpr int JAVASTYLE_CTZ(T x) { |
| 81 | static_assert(std::is_integral<T>::value, "T must be integral"); |
| 82 | using unsigned_type = typename std::make_unsigned<T>::type; |
| 83 | return (x == 0) ? BitSizeOf<T>() : CTZ(static_cast<unsigned_type>(x)); |
| 84 | } |
| 85 | |
| 86 | // Return the number of 1-bits in `x`. |
| 87 | template<typename T> |