diff --git a/include/nameof.hpp b/include/nameof.hpp index 0e67571..ec31083 100644 --- a/include/nameof.hpp +++ b/include/nameof.hpp @@ -269,7 +269,12 @@ struct nameof_enum_supported template struct static_string { - constexpr static_string(std::string_view str) noexcept : static_string{str, std::make_index_sequence{}} {} + constexpr explicit static_string(std::string_view str) noexcept : chars{} { + assert(str.size() == N); + for (std::size_t i = 0; i < N; ++i) { + chars[i] = str[i]; + } + } constexpr const char* data() const noexcept { return chars.data(); } @@ -278,10 +283,7 @@ struct static_string { constexpr operator std::string_view() const noexcept { return {data(), size()}; } private: - template - constexpr static_string(std::string_view str, std::index_sequence) noexcept : chars{{str[I]..., '\0'}} {} - - const std::array chars; + std::array chars; }; template <>