|
|
|
@ -1,7 +1,9 @@
|
|
|
|
|
#pragma once |
|
|
|
|
|
|
|
|
|
#include <cstdint> // uint32_t |
|
|
|
|
#include <limits> // std::numeric_limits |
|
|
|
|
#include <string> // std::string, std::stoul |
|
|
|
|
#include <string> // std::stoul |
|
|
|
|
#include <string_view> |
|
|
|
|
|
|
|
|
|
#include "ruc/meta/assert.h" |
|
|
|
|
|
|
|
|
@ -9,16 +11,11 @@ namespace std {
|
|
|
|
|
|
|
|
|
|
// Can't believe this is not in the standard library
|
|
|
|
|
|
|
|
|
|
inline uint32_t stou(const std::string& string) |
|
|
|
|
inline uint32_t stou(string_view string) |
|
|
|
|
{ |
|
|
|
|
unsigned long size = std::stoul(string); |
|
|
|
|
VERIFY(size <= std::numeric_limits<uint32_t>::max(), "String util not in uint32_t range '{}'", string); |
|
|
|
|
unsigned long size = std::stoul(string.data()); |
|
|
|
|
VERIFY(size <= std::numeric_limits<uint32_t>::max(), "string not in uint32_t range '{}'", string); |
|
|
|
|
return static_cast<uint32_t>(size); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
inline uint32_t stou(const char* string) |
|
|
|
|
{ |
|
|
|
|
return stou(std::string(string)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} // namespace std
|
|
|
|
|