mirror of https://github.com/AxioDL/metaforce.git
hecl/SystemChar: Unify StrLen implementations and make constexpr
We can utilize std::char_traits to generically handle the defined character type. Since C++17, std::char_traits' length() function is constexpr, so we can also make StrLen constexpr.
This commit is contained in:
parent
58e0c7eaa7
commit
216b038a7d
|
@ -26,7 +26,6 @@ namespace hecl {
|
|||
|
||||
#if HECL_UCS2
|
||||
typedef wchar_t SystemChar;
|
||||
static inline size_t StrLen(const SystemChar* str) { return wcslen(str); }
|
||||
typedef std::wstring SystemString;
|
||||
typedef std::wstring_view SystemStringView;
|
||||
static inline void ToLower(SystemString& str) { std::transform(str.begin(), str.end(), str.begin(), towlower); }
|
||||
|
@ -37,7 +36,6 @@ static inline void ToUpper(SystemString& str) { std::transform(str.begin(), str.
|
|||
typedef struct _stat Sstat;
|
||||
#else
|
||||
typedef char SystemChar;
|
||||
static inline size_t StrLen(const SystemChar* str) { return strlen(str); }
|
||||
typedef std::string SystemString;
|
||||
typedef std::string_view SystemStringView;
|
||||
static inline void ToLower(SystemString& str) {
|
||||
|
@ -54,4 +52,6 @@ static inline void ToUpper(SystemString& str) {
|
|||
typedef struct stat Sstat;
|
||||
#endif
|
||||
|
||||
constexpr size_t StrLen(const SystemChar* str) { return std::char_traits<SystemChar>::length(str); }
|
||||
|
||||
} // namespace hecl
|
||||
|
|
Loading…
Reference in New Issue