From 4904822db8770d04444add00a9e155568d3e8bd1 Mon Sep 17 00:00:00 2001 From: neargye Date: Wed, 28 Jun 2023 20:05:12 +0400 Subject: [PATCH] fix CLI/C++ --- include/magic_enum.hpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/include/magic_enum.hpp b/include/magic_enum.hpp index 3769be1..f0ab576 100644 --- a/include/magic_enum.hpp +++ b/include/magic_enum.hpp @@ -434,7 +434,10 @@ constexpr auto n() noexcept { name.str_ += 37; } #elif defined(_MSC_VER) - auto name = str_view{__FUNCSIG__ + 40, sizeof(__FUNCSIG__) - 57}; + str_view name; + name.str_ = __FUNCSIG__; + name.str_ += 40; + name.size_ += sizeof(__FUNCSIG__) - 57; #else auto name = str_view{}; #endif @@ -508,7 +511,9 @@ constexpr auto n() noexcept { #elif defined(_MSC_VER) str_view name; if ((__FUNCSIG__[5] == '_' && __FUNCSIG__[35] != '(') || (__FUNCSIG__[5] == 'c' && __FUNCSIG__[41] != '(')) { - name = str_view{__FUNCSIG__ + 35, sizeof(__FUNCSIG__) - 52}; + name.str_ = __FUNCSIG__; + name.str_ += 35; + name.size_ = sizeof(__FUNCSIG__) - 52; } #else auto name = str_view{}; @@ -543,7 +548,9 @@ constexpr auto n() noexcept { constexpr auto name_ptr = MAGIC_ENUM_GET_ENUM_NAME_BUILTIN(V); auto name = name_ptr ? str_view{name_ptr, std::char_traits::length(name_ptr)} : str_view{}; # else - str_view name = str_view{__FUNCSIG__, sizeof(__FUNCSIG__) - 17}; + str_view name; + name.str_ = __FUNCSIG__; + name.size_ = sizeof(__FUNCSIG__) - 17; std::size_t p = 0; for (std::size_t i = name.size_; i > 0; --i) { if (name.str_[i] == ',' || name.str_[i] == ':') {