From ac2955cb489ba130c879797a70b701c7ed5c1f75 Mon Sep 17 00:00:00 2001 From: gabime Date: Fri, 22 Sep 2023 23:20:54 +0300 Subject: [PATCH] Use std::array for string levels storage --- include/spdlog/common.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/include/spdlog/common.h b/include/spdlog/common.h index bd62579b..fe79e779 100644 --- a/include/spdlog/common.h +++ b/include/spdlog/common.h @@ -16,6 +16,7 @@ #include #include #include +#include #if __has_include() # include @@ -185,17 +186,17 @@ enum level_enum : int #define SPDLOG_SHORT_LEVEL_NAMES {"T", "D", "I", "W", "E", "C", "O"} #endif -constexpr string_view_t level_string_views[] SPDLOG_LEVEL_NAMES; -constexpr const char *short_level_names[] SPDLOG_SHORT_LEVEL_NAMES; +constexpr std::array level_string_views SPDLOG_LEVEL_NAMES; +constexpr std::arrayshort_level_names SPDLOG_SHORT_LEVEL_NAMES; constexpr string_view_t to_string_view(spdlog::level::level_enum lvl) noexcept { - return level_string_views[lvl]; + return level_string_views.at(lvl); } constexpr const char *to_short_c_str(spdlog::level::level_enum lvl) noexcept { - return short_level_names[lvl]; + return short_level_names.at(lvl); } SPDLOG_API spdlog::level::level_enum from_str(const std::string &name) noexcept;