From 840e00b43022db3eb7ae7b662c7721ba44a6c414 Mon Sep 17 00:00:00 2001 From: David Chisnall Date: Tue, 30 Apr 2019 14:08:41 +0100 Subject: [PATCH] Fix sign warning. --- src/ds/bits.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/ds/bits.h b/src/ds/bits.h index 3f0283c..ba96b45 100644 --- a/src/ds/bits.h +++ b/src/ds/bits.h @@ -87,9 +87,13 @@ namespace snmalloc /** * Returns a value of type T that has a single bit set, + * + * S is a template parameter because callers use either `int` or `size_t` + * and either is valid to represent a number in the range 0-63 (or 0-127 if + * we want to use `__uint128_t` as `T`). */ - template - constexpr T one_at_bit(size_t shift) + template + constexpr T one_at_bit(S shift) { static_assert(std::is_integral_v, "Type must be integral"); return (static_cast(1)) << shift;