diff options
author | Benji Dial <benji@benjidial.net> | 2024-07-31 13:36:53 -0400 |
---|---|---|
committer | Benji Dial <benji@benjidial.net> | 2024-07-31 13:36:53 -0400 |
commit | b1cf9e5dfbc8967bd7cb2a22ec1e5e521f4e0e6e (patch) | |
tree | 00837891f9b9bf232e540a6f9b3e16f2438865c3 /euler/include/std/string.hpp | |
parent | 86b343f17175ef3e1fad2197636f75770466aa7c (diff) | |
download | hilbert-os-b1cf9e5dfbc8967bd7cb2a22ec1e5e521f4e0e6e.tar.gz |
add clock
Diffstat (limited to 'euler/include/std/string.hpp')
-rw-r--r-- | euler/include/std/string.hpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/euler/include/std/string.hpp b/euler/include/std/string.hpp index 505ee69..c5a3d99 100644 --- a/euler/include/std/string.hpp +++ b/euler/include/std/string.hpp @@ -12,6 +12,8 @@ namespace std { std::vector<char> characters; public: + static const size_t npos = (size_t)-1; + constexpr string() : characters({'\0'}) {} constexpr string(const string &other) @@ -74,6 +76,14 @@ namespace std { return characters[pos]; } + constexpr string &erase(size_t index = 0, size_t count = npos) { + count = std::min(count, size() - index); + for (size_t i = index; i + count < size(); ++i) + characters[i] = characters[i + count]; + resize(size() - count); + return *this; + } + }; } |