summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--includes/BString.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/includes/BString.h b/includes/BString.h
index b5527d7..568a460 100644
--- a/includes/BString.h
+++ b/includes/BString.h
@@ -95,8 +95,8 @@ class String : private std::string {
bool operator>=(const String & v) const { return compare(v) >= 0; }
bool operator>=(const char * v) const { return compare(v) >= 0; }
- const char & operator[](size_t i) const { return at(i); }
- char & operator[](size_t i) { return at(i); }
+ const char & operator[](size_t i) const { if (i < 0) i = strlen() + i; return at(i); }
+ char & operator[](size_t i) { if (i < 0) i = strlen() + i; return at(i); }
};
};