diff --git a/include/magic_enum/magic_enum.hpp b/include/magic_enum/magic_enum.hpp index cbddc50..ebc6807 100644 --- a/include/magic_enum/magic_enum.hpp +++ b/include/magic_enum/magic_enum.hpp @@ -1363,6 +1363,15 @@ template return enum_name(value); } +// Returns a vector of names from containers' enum. +// If one enum value of the container does not have a name or value out of range, returns empty string. +template typename Container, typename... Args> +[[nodiscard]] constexpr auto enum_name(const Container& values) -> std::vector { + std::vector result; + for (const auto& v: values) result.push_back(magic_enum::enum_name(v)); + return result; +} + // Returns std::array with names, sorted by enum value. template > [[nodiscard]] constexpr auto enum_names() noexcept -> detail::enable_if_t> {