bit_util: Implement MostSignificantBit
This commit is contained in:
parent
95ad0d0a66
commit
b00fe23b91
1 changed files with 5 additions and 0 deletions
|
@ -151,6 +151,11 @@ inline size_t LowestSetBit(T value) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
inline bool MostSignificantBit(T value) {
|
||||||
|
return Bit<BitSize<T>() - 1, T>(value);
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline T Replicate(T value, size_t element_size) {
|
inline T Replicate(T value, size_t element_size) {
|
||||||
ASSERT_MSG(BitSize<T>() % element_size == 0, "bitsize of T not divisible by element_size");
|
ASSERT_MSG(BitSize<T>() % element_size == 0, "bitsize of T not divisible by element_size");
|
||||||
|
|
Loading…
Reference in a new issue