mirror of
https://github.com/Neargye/magic_enum.git
synced 2026-01-10 23:44:29 +00:00
This commit is contained in:
parent
8f933fcfbd
commit
dd2fb1b9a3
1 changed files with 14 additions and 7 deletions
|
|
@ -580,9 +580,9 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
template <class V,
|
||||||
template <typename V = E>
|
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(std::enable_if_t<magic_enum::detail::subtype_v<V> == magic_enum::detail::enum_subtype::flags, E> starter) : a{{}} {
|
constexpr explicit bitset(V starter) : a{{}} {
|
||||||
auto u = enum_underlying(starter);
|
auto u = enum_underlying(starter);
|
||||||
for (E v : enum_values<E>()) {
|
for (E v : enum_values<E>()) {
|
||||||
if (auto ul = enum_underlying(v); (ul & u) != 0) {
|
if (auto ul = enum_underlying(v); (ul & u) != 0) {
|
||||||
|
|
@ -803,6 +803,9 @@ private:
|
||||||
container_type a;
|
container_type a;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <class V, int = 0>
|
||||||
|
explicit bitset(V starter) -> bitset<V>;
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// SET //
|
// SET //
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
@ -847,13 +850,13 @@ public:
|
||||||
insert(e);
|
insert(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
template <class V,
|
||||||
template <typename V = E>
|
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(std::enable_if_t<magic_enum::detail::subtype_v<V> == magic_enum::detail::enum_subtype::flags, E> starter) {
|
constexpr explicit set(V starter) {
|
||||||
auto u = enum_underlying(starter);
|
auto u = enum_underlying(starter);
|
||||||
for (E v : enum_values<E>()) {
|
for (E v : enum_values<E>()) {
|
||||||
if ((enum_underlying(v) & u) != 0) {
|
if ((enum_underlying(v) & u) != 0) {
|
||||||
(*this)[v] = true;
|
insert(v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1095,6 +1098,10 @@ private:
|
||||||
std::size_t s{};
|
std::size_t s{};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template <class V, int = 0>
|
||||||
|
explicit set(V starter) -> set<V>;
|
||||||
|
|
||||||
} // namespace magic_enum::containers
|
} // namespace magic_enum::containers
|
||||||
|
|
||||||
namespace std {
|
namespace std {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue