mirror of
https://github.com/XLabsProject/s1x-client.git
synced 2023-08-02 15:02:12 +02:00
refactor(utils): buff with c++20 to_upper/lower
This commit is contained in:
parent
4966bee83a
commit
8af9e83778
@ -34,24 +34,26 @@ namespace utils::string
|
||||
return elems;
|
||||
}
|
||||
|
||||
std::string to_lower(std::string text)
|
||||
std::string to_lower(const std::string& text)
|
||||
{
|
||||
std::transform(text.begin(), text.end(), text.begin(), [](const unsigned char input)
|
||||
std::string result;
|
||||
std::ranges::transform(text, std::back_inserter(result), [](const unsigned char input)
|
||||
{
|
||||
return static_cast<char>(std::tolower(input));
|
||||
});
|
||||
|
||||
return text;
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string to_upper(std::string text)
|
||||
std::string to_upper(const std::string& text)
|
||||
{
|
||||
std::transform(text.begin(), text.end(), text.begin(), [](const unsigned char input)
|
||||
std::string result;
|
||||
std::ranges::transform(text, std::back_inserter(result), [](const unsigned char input)
|
||||
{
|
||||
return static_cast<char>(std::toupper(input));
|
||||
});
|
||||
|
||||
return text;
|
||||
return result;
|
||||
}
|
||||
|
||||
bool starts_with(const std::string& text, const std::string& substring)
|
||||
|
@ -82,8 +82,8 @@ namespace utils::string
|
||||
|
||||
std::vector<std::string> split(const std::string& s, char delim);
|
||||
|
||||
std::string to_lower(std::string text);
|
||||
std::string to_upper(std::string text);
|
||||
std::string to_lower(const std::string& text);
|
||||
std::string to_upper(const std::string& text);
|
||||
bool starts_with(const std::string& text, const std::string& substring);
|
||||
bool ends_with(const std::string& text, const std::string& substring);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user