From f64bcce564f9c82e0520566c66a39675b18a841b Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Mon, 30 Apr 2018 21:05:21 -0500 Subject: [PATCH] [ox/std] Make rotateLeft a template so it can operate on any size int --- deps/ox/src/ox/std/bitops.hpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/deps/ox/src/ox/std/bitops.hpp b/deps/ox/src/ox/std/bitops.hpp index c6e0d2d5..61607d75 100644 --- a/deps/ox/src/ox/std/bitops.hpp +++ b/deps/ox/src/ox/std/bitops.hpp @@ -12,8 +12,10 @@ namespace ox { -inline uint64_t rotateLeft(uint64_t i, int shift) { - return (i << shift) | (i >> (64 - shift)); +template +inline constexpr T rotateLeft(T i, int shift) { + constexpr auto bits = sizeof(i) * 8; + return (i << shift) | (i >> (bits - shift)); } }