summaryrefslogtreecommitdiff
path: root/euler/include/std/string.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'euler/include/std/string.hpp')
-rw-r--r--euler/include/std/string.hpp10
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;
+ }
+
};
}