added std::string overload of rtrim()
Dieser Commit ist enthalten in:
Ursprung
4730b7ebce
Commit
1715c1db03
@ -23,6 +23,7 @@
|
||||
#ifndef TRAINTASTIC_SERVER_UTILS_RTRIM_HPP
|
||||
#define TRAINTASTIC_SERVER_UTILS_RTRIM_HPP
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <algorithm>
|
||||
|
||||
@ -41,6 +42,16 @@ constexpr std::string_view rtrim(std::string_view s, char c)
|
||||
return {s.data(), size + 1};
|
||||
}
|
||||
|
||||
constexpr std::string& rtrim(std::string& s, char c)
|
||||
{
|
||||
const auto sz = s.size();
|
||||
size_t n = 0;
|
||||
while(n != sz && s[sz - n - 1] == c)
|
||||
n++;
|
||||
s.resize(sz - n);
|
||||
return s;
|
||||
}
|
||||
|
||||
#if __cplusplus >= 202002L
|
||||
constexpr
|
||||
#else
|
||||
|
||||
Laden…
x
In neuem Issue referenzieren
Einen Benutzer sperren