added std::string overload of rtrim()

Dieser Commit ist enthalten in:
Reinder Feenstra 2022-12-24 11:58:44 +01:00
Ursprung 4730b7ebce
Commit 1715c1db03

Datei anzeigen

@ -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