1
0
Fork 0
mirror of https://github.com/Neargye/magic_enum.git synced 2026-01-09 23:34:23 +00:00
Bela Schaum 2023-05-23 18:43:04 +02:00 committed by GitHub
parent 8f933fcfbd
commit dd2fb1b9a3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -580,9 +580,9 @@ public:
}
}
}
template <typename V = E>
constexpr explicit bitset(std::enable_if_t<magic_enum::detail::subtype_v<V> == magic_enum::detail::enum_subtype::flags, E> starter) : a{{}} {
template <class V,
std::enable_if_t<std::is_same_v<V, E> && magic_enum::detail::subtype_v<V> == magic_enum::detail::enum_subtype::flags, int> = 0>
constexpr explicit bitset(V starter) : a{{}} {
auto u = enum_underlying(starter);
for (E v : enum_values<E>()) {
if (auto ul = enum_underlying(v); (ul & u) != 0) {
@ -803,6 +803,9 @@ private:
container_type a;
};
template <class V, int = 0>
explicit bitset(V starter) -> bitset<V>;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// SET //
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -847,13 +850,13 @@ public:
insert(e);
}
}
template <typename V = E>
constexpr explicit set(std::enable_if_t<magic_enum::detail::subtype_v<V> == magic_enum::detail::enum_subtype::flags, E> starter) {
template <class V,
std::enable_if_t<std::is_same_v<V, E> &&magic_enum::detail::subtype_v<V> == magic_enum::detail::enum_subtype::flags, int> = 0>
constexpr explicit set(V starter) {
auto u = enum_underlying(starter);
for (E v : enum_values<E>()) {
if ((enum_underlying(v) & u) != 0) {
(*this)[v] = true;
insert(v);
}
}
}
@ -1095,6 +1098,10 @@ private:
std::size_t s{};
};
template <class V, int = 0>
explicit set(V starter) -> set<V>;
} // namespace magic_enum::containers
namespace std {