Make BufferIterator::operator* return a const ref to be more compatible

This commit is contained in:
Maxime Coste 2016-01-27 08:27:23 +00:00
parent 04119d6207
commit f8106690b1
2 changed files with 6 additions and 6 deletions

View File

@ -64,8 +64,8 @@ public:
bool operator> (const BufferIterator& iterator) const;
bool operator>= (const BufferIterator& iterator) const;
char operator* () const;
char operator[](size_t n) const;
const char& operator* () const;
const char& operator[](size_t n) const;
size_t operator- (const BufferIterator& iterator) const;
BufferIterator operator+ (ByteCount size) const;
@ -133,7 +133,7 @@ public:
String string(ByteCoord begin, ByteCoord end) const;
char byte_at(ByteCoord c) const;
const char& byte_at(ByteCoord c) const;
ByteCount distance(ByteCoord begin, ByteCoord end) const;
ByteCoord advance(ByteCoord coord, ByteCount count) const;
ByteCoord next(ByteCoord coord) const;

View File

@ -7,7 +7,7 @@ namespace Kakoune
{
[[gnu::always_inline]]
inline char Buffer::byte_at(ByteCoord c) const
inline const char& Buffer::byte_at(ByteCoord c) const
{
kak_assert(c.line < line_count() and c.column < m_lines[c.line].length());
return m_lines[c.line][c.column];
@ -152,12 +152,12 @@ inline bool BufferIterator::operator>=(const BufferIterator& iterator) const
}
[[gnu::always_inline]]
inline char BufferIterator::operator*() const
inline const char& BufferIterator::operator*() const
{
return m_buffer->byte_at(m_coord);
}
inline char BufferIterator::operator[](size_t n) const
inline const char& BufferIterator::operator[](size_t n) const
{
return m_buffer->byte_at(m_buffer->advance(m_coord, n));
}