mirror of
https://github.com/Neargye/magic_enum.git
synced 2026-01-09 23:34:23 +00:00
Explicitly mark the result of detail::names as constexpr (#305)
It might make no sense, but on MSVC it can generate a compile-time error, especially if an enumerator's value is out of range. Example: error C3615: constexpr function 'magic_enum::detail::names' cannot result in a constant expression ... note: failure was caused by call of undefined function or one not declared 'constexpr' ... note: see usage of '__builtin_array_init_helper'
This commit is contained in:
parent
5cf4eb3a53
commit
5523803cfc
2 changed files with 14 additions and 1 deletions
|
|
@ -829,7 +829,8 @@ inline constexpr auto max_v = (count_v<E, S> > 0) ? static_cast<U>(values_v<E, S
|
|||
|
||||
template <typename E, enum_subtype S, std::size_t... I>
|
||||
constexpr auto names(std::index_sequence<I...>) noexcept {
|
||||
return std::array<string_view, sizeof...(I)>{{enum_name_v<E, values_v<E, S>[I]>...}};
|
||||
constexpr auto result = std::array<string_view, sizeof...(I)>{{enum_name_v<E, values_v<E, S>[I]>...}};
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename E, enum_subtype S>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue