From b1cf9e5dfbc8967bd7cb2a22ec1e5e521f4e0e6e Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Wed, 31 Jul 2024 13:36:53 -0400 Subject: add clock --- euler/include/std/string.hpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'euler/include/std/string.hpp') 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 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; + } + }; } -- cgit v1.2.3