MCPcopy Create free account
hub / github.com/CodingGay/BlackDex / CTZ

Function CTZ

Bcore/src/main/cpp/base/bit_utils.h:68–76  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

66
67template<typename T>
68constexpr int CTZ(T x) {
69 static_assert(std::is_integral<T>::value, "T must be integral");
70 // It is not unreasonable to ask for trailing zeros in a negative number. As such, do not check
71 // that T is an unsigned type.
72 static_assert(sizeof(T) == sizeof(uint64_t) || sizeof(T) <= sizeof(uint32_t),
73 "Unsupported sizeof(T)");
74 DCHECK_NE(x, static_cast<T>(0));
75 return (sizeof(T) == sizeof(uint64_t)) ? __builtin_ctzll(x) : __builtin_ctz(x);
76}
77
78// Similar to CTZ except that on zero input it returns bitwidth and supports signed integers.
79template<typename T>

Callers 4

JAVASTYLE_CTZFunction · 0.85
LeastSignificantBitFunction · 0.85
WhichPowerOf2Function · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected