mirror of
https://github.com/gabime/spdlog.git
synced 2025-01-13 09:20:25 +08:00
small std::find conversion
Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
parent
0a92d1d684
commit
1ef2f014ee
@ -7,6 +7,9 @@
|
|||||||
#include <spdlog/common.h>
|
#include <spdlog/common.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <iterator>
|
||||||
|
|
||||||
namespace spdlog {
|
namespace spdlog {
|
||||||
namespace level {
|
namespace level {
|
||||||
|
|
||||||
@ -31,15 +34,10 @@ SPDLOG_INLINE const char *to_short_c_str(spdlog::level::level_enum l) SPDLOG_NOE
|
|||||||
|
|
||||||
SPDLOG_INLINE spdlog::level::level_enum from_str(const std::string &name) SPDLOG_NOEXCEPT
|
SPDLOG_INLINE spdlog::level::level_enum from_str(const std::string &name) SPDLOG_NOEXCEPT
|
||||||
{
|
{
|
||||||
int level = 0;
|
auto it = std::find(std::begin(level_string_views), std::end(level_string_views), name);
|
||||||
for (const auto &level_str : level_string_views)
|
if (it != std::end(level_string_views))
|
||||||
{
|
return static_cast<level::level_enum>(std::distance(std::begin(level_string_views), it));
|
||||||
if (level_str == name)
|
|
||||||
{
|
|
||||||
return static_cast<level::level_enum>(level);
|
|
||||||
}
|
|
||||||
level++;
|
|
||||||
}
|
|
||||||
// check also for "warn" and "err" before giving up..
|
// check also for "warn" and "err" before giving up..
|
||||||
if (name == "warn")
|
if (name == "warn")
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user