diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2012-08-23 23:56:35 +0200 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2012-08-23 23:56:35 +0200 |
| commit | e4fd839ddaaf3fc68df2cb502a633a2ae6a9f86f (patch) | |
| tree | 681b2a63eb9b9497b97697e3f1479a7b20270427 /src/string.hh | |
| parent | 0d8cce272831cd896d0e69d7c86cc9afc521eb11 (diff) | |
use a strongly typed int CharCount for character counts
Diffstat (limited to 'src/string.hh')
| -rw-r--r-- | src/string.hh | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/string.hh b/src/string.hh index cd5cfe1d..58dd79b7 100644 --- a/src/string.hh +++ b/src/string.hh @@ -5,6 +5,7 @@ #include <iosfwd> #include "memoryview.hh" +#include "units.hh" namespace Kakoune { @@ -23,8 +24,8 @@ public: template<typename Iterator> String(Iterator begin, Iterator end) : m_content(begin, end) {} - Character operator[](size_t pos) const { return static_cast<Character>(m_content[pos]); } - size_t length() const { return m_content.length(); } + Character operator[](CharCount pos) const { return static_cast<Character>(m_content[(int)pos]); } + CharCount length() const { return m_content.length(); } bool empty() const { return m_content.empty(); } bool operator== (const String& other) const { return m_content == other.m_content; } @@ -43,7 +44,7 @@ public: memoryview<char> data() const { return memoryview<char>(m_content.data(), m_content.size()); } const char* c_str() const { return m_content.c_str(); } - String substr(size_t pos, size_t length = -1) const { return String(m_content.substr(pos, length)); } + String substr(CharCount pos, CharCount length = -1) const { return String(m_content.substr((int)pos, (int)length)); } class iterator { |
