Skip to content
Open
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
8 changes: 8 additions & 0 deletions include/magic_enum/magic_enum_flags.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ template <typename E>
constexpr auto S = detail::enum_subtype::flags;
static_assert(detail::is_reflected_v<D, S>, "magic_enum requires enum implementation and valid max and min.");

// There might be a name for value 0 (when no flags are set).
if constexpr(enum_contains<E>(0)) {
if(static_cast<U>(value) == 0) {
constexpr string_view zeroName = detail::enum_name_v<D, static_cast<D>(0)>;
return string(zeroName);
}
}

string name;
auto check_value = U{0};
for (std::size_t i = 0; i < detail::count_v<D, S>; ++i) {
Expand Down