From 341521b9c05f211300e5533a44af45e7c42c9355 Mon Sep 17 00:00:00 2001 From: neargye Date: Fri, 21 Nov 2025 19:06:51 +0400 Subject: [PATCH] fix build --- .github/workflows/windows.yml | 2 +- include/magic_enum/magic_enum.hpp | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 3fae50a..2947ed0 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -12,7 +12,7 @@ jobs: matrix: config: - { os: windows-2022, vs: "Visual Studio 2022" } - - { os: windows-2025, vs: "Visual Studio 2022" } + - { os: windows-2025, vs: "Visual Studio 2025" } name: "${{ matrix.config.vs }}" steps: diff --git a/include/magic_enum/magic_enum.hpp b/include/magic_enum/magic_enum.hpp index cbd388f..29ad7a0 100644 --- a/include/magic_enum/magic_enum.hpp +++ b/include/magic_enum/magic_enum.hpp @@ -181,7 +181,7 @@ namespace detail { constexpr inline std::size_t prefix_length_or_zero = 0; template - inline auto prefix_length_or_zero::prefix_length)>> = std::size_t{ customize::enum_range::prefix_length }; + constexpr inline auto prefix_length_or_zero::prefix_length)>> = std::size_t{customize::enum_range::prefix_length}; } namespace customize { @@ -335,11 +335,14 @@ class static_str<0> { constexpr static_str(string_view) noexcept {} - constexpr const char_type* data() const noexcept { return nullptr; } + constexpr const char_type* data() const noexcept { return chars_; } constexpr std::uint16_t size() const noexcept { return 0; } - constexpr string_view str() const noexcept { return ""; } + constexpr string_view str() const noexcept { return string_view(data(), size()); } + +private: + static constexpr char_type chars_[1] = {}; }; template > @@ -1215,7 +1218,7 @@ using enum_constant = detail::enum_constant; // Returns type name of enum. template [[nodiscard]] constexpr auto enum_type_name() noexcept -> detail::enable_if_t { - constexpr string_view name = detail::type_name_v>; + constexpr string_view name = detail::type_name_v>.str(); static_assert(!name.empty(), "magic_enum::enum_type_name enum type does not have a name."); return name; @@ -1346,7 +1349,7 @@ template > if (const auto i = enum_index(value)) { return detail::names_v[*i]; } - return ""; + return detail::static_str<0>{}.str(); } // Returns name from enum value.