Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions include/stdx/bitset.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,16 +341,16 @@ class bitset {
return n + static_cast<std::size_t>(popcount(highbits()));
}

[[nodiscard]] constexpr auto lowest_unset() const -> std::size_t {
[[nodiscard]] constexpr auto lowest_unset() const {
std::size_t i = 0;
for (auto e : storage) {
if (auto offset = static_cast<std::size_t>(countr_one(e));
offset != std::numeric_limits<elem_t>::digits) {
return i + offset;
return static_cast<iter_arg_t>(i + offset);
}
i += std::numeric_limits<elem_t>::digits;
}
return i;
return static_cast<iter_arg_t>(i);
}

[[nodiscard]] constexpr auto operator~() const -> bitset {
Expand Down
5 changes: 5 additions & 0 deletions test/bitset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,11 @@ TEST_CASE("use bitset with enum struct (transform_reduce)", "[bitset]") {
bs));
}

TEST_CASE("use bitset with enum struct (lowest_unset)", "[bitset]") {
constexpr auto bs = stdx::bitset<Bits::MAX>{stdx::place_bits, Bits::ZERO};
CHECK(bs.lowest_unset() == Bits::ONE);
}

#if __cplusplus >= 202002L
TEST_CASE("construct with a ct_string", "[bitset]") {
using namespace stdx::literals;
Expand Down
Loading