From e4fd839ddaaf3fc68df2cb502a633a2ae6a9f86f Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Thu, 23 Aug 2012 23:56:35 +0200 Subject: use a strongly typed int CharCount for character counts --- src/string.hh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/string.hh') 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 #include "memoryview.hh" +#include "units.hh" namespace Kakoune { @@ -23,8 +24,8 @@ public: template String(Iterator begin, Iterator end) : m_content(begin, end) {} - Character operator[](size_t pos) const { return static_cast(m_content[pos]); } - size_t length() const { return m_content.length(); } + Character operator[](CharCount pos) const { return static_cast(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 data() const { return memoryview(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 { -- cgit v1.2.3