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

fix bitset constructor (#367)

This commit is contained in:
asolwa 2024-07-19 14:51:58 +02:00 committed by GitHub
parent 664ee62c12
commit 9a9308fd54
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -621,14 +621,14 @@ class bitset {
constexpr explicit bitset(string_view sv, Cmp&& cmp = {}, char_type sep = static_cast<char_type>('|')) { constexpr explicit bitset(string_view sv, Cmp&& cmp = {}, char_type sep = static_cast<char_type>('|')) {
for (std::size_t to = 0; (to = magic_enum::detail::find(sv, sep)) != string_view::npos; sv.remove_prefix(to + 1)) { for (std::size_t to = 0; (to = magic_enum::detail::find(sv, sep)) != string_view::npos; sv.remove_prefix(to + 1)) {
if (auto v = enum_cast<E>(sv.substr(0, to), cmp)) { if (auto v = enum_cast<E>(sv.substr(0, to), cmp)) {
set(v); set(*v);
} else { } else {
MAGIC_ENUM_THROW(std::invalid_argument("magic_enum::containers::bitset::constructor: Unrecognized enum value in string")); MAGIC_ENUM_THROW(std::invalid_argument("magic_enum::containers::bitset::constructor: Unrecognized enum value in string"));
} }
} }
if (!sv.empty()) { if (!sv.empty()) {
if (auto v = enum_cast<E>(sv, cmp)) { if (auto v = enum_cast<E>(sv, cmp)) {
set(v); set(*v);
} else { } else {
MAGIC_ENUM_THROW(std::invalid_argument("magic_enum::containers::bitset::constructor: Unrecognized enum value in string")); MAGIC_ENUM_THROW(std::invalid_argument("magic_enum::containers::bitset::constructor: Unrecognized enum value in string"));
} }