diff --git a/include/magic_enum/magic_enum.hpp b/include/magic_enum/magic_enum.hpp index 00f8257..d99bb34 100644 --- a/include/magic_enum/magic_enum.hpp +++ b/include/magic_enum/magic_enum.hpp @@ -318,7 +318,14 @@ class static_str { constexpr std::uint16_t size() const noexcept { return N; } - constexpr operator string_view() const noexcept { return {data(), size()}; } + // MSVC C++20/23 module compatibility: explicit conversion method + [[nodiscard]] constexpr string_view str() const noexcept { + return string_view(data(), size()); + } + + #if !defined(MAGIC_ENUM_USE_STD_MODULE) || !defined(_MSC_VER) + constexpr operator string_view() const noexcept { return str(); } + #endif private: template @@ -886,7 +893,8 @@ inline constexpr auto max_v = (count_v > 0) ? static_cast(values_v constexpr auto names(std::index_sequence) noexcept { - constexpr auto names = std::array{{enum_name_v[I]>...}}; + // MSVC module compatibility: explicit call to str() instead of implicit conversion + constexpr auto names = std::array{{enum_name_v[I]>.str()...}}; return names; }