From b00fe23b91dc653e65d814e34cd61d41ecd44b2d Mon Sep 17 00:00:00 2001 From: MerryMage Date: Thu, 28 Jun 2018 21:44:35 +0100 Subject: [PATCH] bit_util: Implement MostSignificantBit --- src/common/bit_util.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/common/bit_util.h b/src/common/bit_util.h index b83fc6ec..25ed3fc3 100644 --- a/src/common/bit_util.h +++ b/src/common/bit_util.h @@ -151,6 +151,11 @@ inline size_t LowestSetBit(T value) { return result; } +template +inline bool MostSignificantBit(T value) { + return Bit() - 1, T>(value); +} + template inline T Replicate(T value, size_t element_size) { ASSERT_MSG(BitSize() % element_size == 0, "bitsize of T not divisible by element_size");