1
0
Fork 0
mirror of https://github.com/Neargye/magic_enum.git synced 2026-01-09 23:34:23 +00:00

Fix set erase function (#308)

This commit is contained in:
Ryan Samarakoon 2023-11-13 00:30:10 +11:00 committed by GitHub
parent 3c92e9035b
commit cd5fd2c343
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View file

@ -982,7 +982,7 @@ class set {
constexpr size_type erase(const key_type& key) noexcept {
typename container_type::reference ref = a[key];
bool res = ref;
bool res = static_cast<bool>(ref);
if (res) {
--s;
}

View file

@ -270,6 +270,12 @@ TEST_CASE("containers_set") {
REQUIRE_FALSE(color_set.empty());
REQUIRE(color_set.size() == 3);
REQUIRE(magic_enum::enum_count<Color>() == color_set.size());
color_set.erase(Color::RED);
color_set.erase(Color::GREEN);
REQUIRE(magic_enum::enum_count<Color>() - 2 == color_set.size());
REQUIRE(color_set.count(Color::RED) == 0);
REQUIRE_FALSE(color_set.contains(Color::GREEN));
REQUIRE(color_set.contains(Color::BLUE));
auto color_set_compare = magic_enum::containers::set<Color>();
color_set_compare.insert(Color::BLUE);