From e042c63de6c7c67e25636496ed5c90794f3df7ba Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 4 Mar 2019 09:21:29 -0500 Subject: [PATCH] common/bit_util: Make a few functions as constexpr These four functions can be made constexpr with no issue. --- src/common/bit_util.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/common/bit_util.h b/src/common/bit_util.h index 4da42e31..4eea814c 100644 --- a/src/common/bit_util.h +++ b/src/common/bit_util.h @@ -121,7 +121,7 @@ constexpr T ModifyBit(const T value, bool new_bit) { /// Sign-extends a value that has bit_count bits to the full bitwidth of type T. template -inline T SignExtend(const T value) { +constexpr T SignExtend(const T value) { static_assert(bit_count <= BitSize(), "bit_count larger than bitsize of T"); constexpr T mask = static_cast(1ULL << bit_count) - 1; @@ -162,7 +162,7 @@ constexpr int HighestSetBit(T value) { } template -inline size_t LowestSetBit(T value) { +constexpr size_t LowestSetBit(T value) { auto x = static_cast>(value); if (x == 0) return BitSize(); @@ -176,7 +176,7 @@ inline size_t LowestSetBit(T value) { } template -inline bool MostSignificantBit(T value) { +constexpr bool MostSignificantBit(T value) { return Bit() - 1, T>(value); } @@ -189,7 +189,7 @@ inline T Replicate(T value, size_t element_size) { } template -inline T RotateRight(T value, size_t amount) { +constexpr T RotateRight(T value, size_t amount) { amount %= BitSize(); if (amount == 0) {