Skip to content

Commit 95b2f52

Browse files
committed
Fix declaration of countr_zero and switch to inline constexpr
1 parent 75606d3 commit 95b2f52

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

include/gtl/bit_vector.hpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,31 +25,31 @@ namespace gtl {
2525

2626
namespace bitv {
2727

28-
static constexpr size_t stride = 64;
29-
static constexpr uint64_t ones = (uint64_t)-1;
28+
inline constexpr size_t stride = 64;
29+
inline constexpr uint64_t ones = (uint64_t)-1;
3030

31-
static constexpr size_t mod(size_t n) { return (n & 0x3f); }
32-
static constexpr size_t slot(size_t n) { return n >> 6; }
33-
static constexpr size_t slot_cnt(size_t n) { return slot(n + 63); }
31+
inline constexpr size_t mod(size_t n) { return (n & 0x3f); }
32+
inline constexpr size_t slot(size_t n) { return n >> 6; }
33+
inline constexpr size_t slot_cnt(size_t n) { return slot(n + 63); }
3434

3535
// a mask for this bit in its slot
36-
static constexpr uint64_t bitmask(size_t n) { return (uint64_t)1 << mod(n); }
36+
inline constexpr uint64_t bitmask(size_t n) { return (uint64_t)1 << mod(n); }
3737

3838
// a mask for bits lower than n in slot
39-
static constexpr uint64_t lowmask(size_t n) { return bitmask(n) - 1; }
39+
inline constexpr uint64_t lowmask(size_t n) { return bitmask(n) - 1; }
4040

4141
// a mask for bits higher than n-1 in slot
42-
static constexpr uint64_t himask(size_t n) { return ~lowmask(n); }
42+
inline constexpr uint64_t himask(size_t n) { return ~lowmask(n); }
4343

44-
static constexpr size_t _popcount64(uint64_t y) {
44+
inline constexpr size_t _popcount64(uint64_t y) {
4545
// https://gist.github.com/enjoylife/4091854
4646
y -= ((y >> 1) & 0x5555555555555555ull);
4747
y = (y & 0x3333333333333333ull) + (y >> 2 & 0x3333333333333333ull);
4848
return ((y + (y >> 4)) & 0xf0f0f0f0f0f0f0full) * 0x101010101010101ull >> 56;
4949
}
5050

5151
// De Bruijn Multiplication With separated LS1B - author Kim Walisch (2012)
52-
unsigned countr_zero(uint64_t bb) {
52+
inline constexpr unsigned countr_zero(uint64_t bb) {
5353
const unsigned index64[64] = { 0, 47, 1, 56, 48, 27, 2, 60, 57, 49, 41, 37, 28, 16, 3, 61,
5454
54, 58, 35, 52, 50, 42, 21, 44, 38, 32, 29, 23, 17, 11, 4, 62,
5555
46, 55, 26, 59, 40, 36, 15, 53, 34, 51, 20, 43, 31, 22, 10, 45,

0 commit comments

Comments
 (0)