summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPixel <pixel@nobis-crew.org>2011-11-24 11:06:02 -0800
committerPixel <pixel@nobis-crew.org>2011-11-24 11:06:02 -0800
commitbf8f22b1f5b990c82993a9466f1da7c5226b1f8e (patch)
treef294574aa2e7427abff21ee72dc4b1dbaaa4ce50
parent0b666e97720ca4e4df11df146a92488b91447a69 (diff)
Making strings being able to read from their end.
-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); }
};
};