diff --git a/include/magic_enum/magic_enum_flags.hpp b/include/magic_enum/magic_enum_flags.hpp index 54a5507..abe5a68 100644 --- a/include/magic_enum/magic_enum_flags.hpp +++ b/include/magic_enum/magic_enum_flags.hpp @@ -70,6 +70,14 @@ template constexpr auto S = detail::enum_subtype::flags; static_assert(detail::is_reflected_v, "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(0)) { + if(static_cast(value) == 0) { + constexpr string_view zeroName = detail::enum_name_v(0)>; + return string(zeroName); + } + } + string name; auto check_value = U{0}; for (std::size_t i = 0; i < detail::count_v; ++i) {