Added std::conditional_t<(BITS <= 16), bitset_detail::IntBitSet<uint16_t>, ...
and removed the I()
, wrote unit test in bc36241f5a0a23d16645155eb819e94b0db2813e, and it indeed proves you are correct. Right now it cannot occur since IntBitSet<uint32_t>
is the smallest we go, but better not to leave loaded footguns lying around.
0$ src/test/test_bitcoin -t bitset_tests
1...
2Running 1 test case...
3test/bitset_tests.cpp(18): error: in "bitset_tests/bitset_test_15": check std::popcount(sim) == set.Count() has failed [1 != 16]
4test/bitset_tests.cpp(18): error: in "bitset_tests/bitset_test_15": check std::popcount(sim) == set.Count() has failed [2 != 16]
5test/bitset_tests.cpp(18): error: in "bitset_tests/bitset_test_15": check std::popcount(sim) == set.Count() has failed [3 != 16]
6test/bitset_tests.cpp(18): error: in "bitset_tests/bitset_test_15": check std::popcount(sim) == set.Count() has failed [4 != 16]
7test/bitset_tests.cpp(18): error: in "bitset_tests/bitset_test_15": check std::popcount(sim) == set.Count() has failed [5 != 16]
8test/bitset_tests.cpp(18): error: in "bitset_tests/bitset_test_15": check std::popcount(sim) == set.Count() has failed [6 != 16]
9test/bitset_tests.cpp(18): error: in "bitset_tests/bitset_test_15": check std::popcount(sim) == set.Count() has failed [7 != 16]
10test/bitset_tests.cpp(18): error: in "bitset_tests/bitset_test_15": check std::popcount(sim) == set.Count() has failed [8 != 16]
11test/bitset_tests.cpp(18): error: in "bitset_tests/bitset_test_15": check std::popcount(sim) == set.Count() has failed [9 != 16]
12test/bitset_tests.cpp(18): error: in "bitset_tests/bitset_test_15": check std::popcount(sim) == set.Count() has failed [10 != 16]
13test/bitset_tests.cpp(18): error: in "bitset_tests/bitset_test_15": check std::popcount(sim) == set.Count() has failed [11 != 16]
14test/bitset_tests.cpp(18): error: in "bitset_tests/bitset_test_15": check std::popcount(sim) == set.Count() has failed [12 != 16]
15test/bitset_tests.cpp(18): error: in "bitset_tests/bitset_test_15": check std::popcount(sim) == set.Count() has failed [13 != 16]
16test/bitset_tests.cpp(18): error: in "bitset_tests/bitset_test_15": check std::popcount(sim) == set.Count() has failed [14 != 16]
17test/bitset_tests.cpp(18): error: in "bitset_tests/bitset_test_15": check std::popcount(sim) == set.Count() has failed [15 != 16]