diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-12 14:27:29 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-13 09:35:20 +0000 |
commit | c30a6232df03e1efbd9f3b226777b07e087a1122 (patch) | |
tree | e992f45784689f373bcc38d1b79a239ebe17ee23 /chromium/base/bits.h | |
parent | 7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3 (diff) | |
download | qtwebengine-chromium-85-based.tar.gz |
BASELINE: Update Chromium to 85.0.4183.14085-based
Change-Id: Iaa42f4680837c57725b1344f108c0196741f6057
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/base/bits.h')
-rw-r--r-- | chromium/base/bits.h | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/chromium/base/bits.h b/chromium/base/bits.h index d2c5ac9caa7..20f2ff278f3 100644 --- a/chromium/base/bits.h +++ b/chromium/base/bits.h @@ -7,13 +7,14 @@ #ifndef BASE_BITS_H_ #define BASE_BITS_H_ +#include <limits.h> #include <stddef.h> #include <stdint.h> #include <type_traits> +#include "base/check.h" #include "base/compiler_specific.h" -#include "base/logging.h" #include "build/build_config.h" #if defined(COMPILER_MSVC) @@ -203,6 +204,16 @@ inline int Log2Ceiling(uint32_t n) { return (n ? 32 : -1) - CountLeadingZeroBits(n - 1); } +// Returns a value of type T with a single bit set in the left-most position. +// Can be used instead of manually shifting a 1 to the left. +template <typename T> +constexpr T LeftmostBit() { + static_assert(std::is_integral<T>::value, + "This function can only be used with integral types."); + T one(1u); + return one << ((CHAR_BIT * sizeof(T) - 1)); +} + } // namespace bits } // namespace base |