| 59 | // Similar to CLZ except that on zero input it returns bitwidth and supports signed integers. |
| 60 | template<typename T> |
| 61 | constexpr int JAVASTYLE_CLZ(T x) { |
| 62 | static_assert(std::is_integral<T>::value, "T must be integral"); |
| 63 | using unsigned_type = typename std::make_unsigned<T>::type; |
| 64 | return (x == 0) ? BitSizeOf<T>() : CLZ(static_cast<unsigned_type>(x)); |
| 65 | } |
| 66 | |
| 67 | template<typename T> |
| 68 | constexpr int CTZ(T x) { |