23 using std::string::string;
26 explicit string(
const std::string &str) : std::string(str) {}
43 string operator*(
int times)
const {
46 r.reserve(string::size() * times);
70 string operator|(
const T x)
const {
71 static_assert(std::is_same<T, rush::color::fg>::value || std::is_same<T, rush::color::bg>::value || std::is_same<T, rush::color::st>::value);
72 constexpr size_t s1 = std::char_traits<char>::length(rush::color::reset);
73 const std::size_t s2 = string::size();
74 if(s1 >= s2 || string::substr(s2 - s1) != rush::color::reset) {
75 return static_cast<string>(rush::color::escape_sequence(
static_cast<int>(x)) + *
this + rush::color::reset);
77 return static_cast<string>(rush::color::escape_sequence(
static_cast<int>(x)) + *
this);
96 string replaceSubstr(
const std::string &from,
const std::string &to) {
97 const std::size_t lf = from.length();
98 const std::size_t lt = to.length();
99 std::size_t index = -lt;
101 while((index = ret.find(from, index + lt)) != std::string::npos) {
102 ret.replace(index, lf, to);
122 int countSubstr(
const std::string &substr) {
123 const std::size_t n = substr.length();
125 std::size_t index = -n;
126 while((index = std::string::find(substr, index + n)) != std::string::npos) {
constexpr const T & clampl(const T &v, const T &lo)
Clamps a value to be not less than a specified lower bound.
Definition algorithm.hpp:45