Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/base
diff options
context:
space:
mode:
authorYuri Gorshenin <y@maps.me>2016-07-13 14:22:26 +0300
committerYuri Gorshenin <y@maps.me>2016-07-13 18:16:24 +0300
commitacd3f65c50c047dc3a529a8e387eda5d11f17fbc (patch)
tree11c6b1706d4c995ce8824c951aba71651d7d3a50 /base
parent1f3b320876d20e269575b421eac4e96105d84a1b (diff)
[coding] Elias gamma and delta coder.
Diffstat (limited to 'base')
-rw-r--r--base/bits.hpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/base/bits.hpp b/base/bits.hpp
index 4c561f3422..94c5d501db 100644
--- a/base/bits.hpp
+++ b/base/bits.hpp
@@ -2,9 +2,9 @@
#include "base/assert.hpp"
#include "std/cstdint.hpp"
+#include "std/limits.hpp"
#include "std/type_traits.hpp"
-
namespace bits
{
// Count the number of 1 bits. Implementation: see Hacker's delight book.
@@ -201,4 +201,11 @@ namespace bits
while (n != 0) { ++result; n >>= 1; }
return result;
}
-}
+
+ inline uint64_t GetFullMask(uint8_t numBits)
+ {
+ ASSERT_LESS_OR_EQUAL(numBits, 64, ());
+ return numBits == 64 ? numeric_limits<uint64_t>::max()
+ : (static_cast<uint64_t>(1) << numBits) - 1;
+ }
+} // namespace bits