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

Function MaskLeastSignificant

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

Source from the content-addressed store, hash-verified

388// msb lsb
389template <typename T = size_t>
390inline static constexpr std::make_unsigned_t<T> MaskLeastSignificant(size_t bits) {
391 DCHECK_GE(BitSizeOf<T>(), bits) << "Bits out of range for type T";
392 using unsigned_T = std::make_unsigned_t<T>;
393 if (bits >= BitSizeOf<T>()) {
394 return std::numeric_limits<unsigned_T>::max();
395 } else {
396 auto kOne = static_cast<unsigned_T>(1); // Do not truncate for T>size_t.
397 return static_cast<unsigned_T>((kOne << bits) - kOne);
398 }
399}
400
401// Clears the bitfield starting at the least significant bit "lsb" with a bitwidth of 'width'.
402// (Equivalent of ARM BFC instruction).

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected