noexept-ify BufferIterator methods
This commit is contained in:
parent
502c5da0e9
commit
cb6ef4afb6
|
@ -59,18 +59,18 @@ public:
|
||||||
// costly, so this is not strictly random access
|
// costly, so this is not strictly random access
|
||||||
using iterator_category = std::bidirectional_iterator_tag;
|
using iterator_category = std::bidirectional_iterator_tag;
|
||||||
|
|
||||||
BufferIterator() : m_buffer(nullptr) {}
|
BufferIterator() noexcept : m_buffer(nullptr) {}
|
||||||
BufferIterator(const Buffer& buffer, BufferCoord coord);
|
BufferIterator(const Buffer& buffer, BufferCoord coord) noexcept;
|
||||||
|
|
||||||
bool operator== (const BufferIterator& iterator) const;
|
bool operator== (const BufferIterator& iterator) const noexcept;
|
||||||
bool operator!= (const BufferIterator& iterator) const;
|
bool operator!= (const BufferIterator& iterator) const noexcept;
|
||||||
bool operator< (const BufferIterator& iterator) const;
|
bool operator< (const BufferIterator& iterator) const noexcept;
|
||||||
bool operator<= (const BufferIterator& iterator) const;
|
bool operator<= (const BufferIterator& iterator) const noexcept;
|
||||||
bool operator> (const BufferIterator& iterator) const;
|
bool operator> (const BufferIterator& iterator) const noexcept;
|
||||||
bool operator>= (const BufferIterator& iterator) const;
|
bool operator>= (const BufferIterator& iterator) const noexcept;
|
||||||
|
|
||||||
const char& operator* () const;
|
const char& operator* () const noexcept;
|
||||||
const char& operator[](size_t n) const;
|
const char& operator[](size_t n) const noexcept;
|
||||||
size_t operator- (const BufferIterator& iterator) const;
|
size_t operator- (const BufferIterator& iterator) const;
|
||||||
|
|
||||||
BufferIterator operator+ (ByteCount size) const;
|
BufferIterator operator+ (ByteCount size) const;
|
||||||
|
@ -85,7 +85,7 @@ public:
|
||||||
BufferIterator operator++ (int);
|
BufferIterator operator++ (int);
|
||||||
BufferIterator operator-- (int);
|
BufferIterator operator-- (int);
|
||||||
|
|
||||||
const BufferCoord& coord() const { return m_coord; }
|
const BufferCoord& coord() const noexcept { return m_coord; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SafePtr<const Buffer> m_buffer;
|
SafePtr<const Buffer> m_buffer;
|
||||||
|
|
|
@ -114,55 +114,52 @@ inline BufferCoord Buffer::end_coord() const
|
||||||
BufferCoord{0,0} : BufferCoord{ line_count() - 1, m_lines.back().length() };
|
BufferCoord{0,0} : BufferCoord{ line_count() - 1, m_lines.back().length() };
|
||||||
}
|
}
|
||||||
|
|
||||||
inline BufferIterator::BufferIterator(const Buffer& buffer, BufferCoord coord)
|
inline BufferIterator::BufferIterator(const Buffer& buffer, BufferCoord coord) noexcept
|
||||||
: m_buffer(&buffer), m_coord(coord),
|
: m_buffer(&buffer), m_coord(coord),
|
||||||
m_line((*m_buffer)[coord.line]),
|
m_line((*m_buffer)[coord.line]),
|
||||||
m_last_line(buffer.line_count()-1)
|
m_last_line(buffer.line_count()-1) {}
|
||||||
{
|
|
||||||
kak_assert(m_buffer and m_buffer->is_valid(m_coord));
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool BufferIterator::operator==(const BufferIterator& iterator) const
|
inline bool BufferIterator::operator==(const BufferIterator& iterator) const noexcept
|
||||||
{
|
{
|
||||||
return m_buffer == iterator.m_buffer and m_coord == iterator.m_coord;
|
return m_buffer == iterator.m_buffer and m_coord == iterator.m_coord;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool BufferIterator::operator!=(const BufferIterator& iterator) const
|
inline bool BufferIterator::operator!=(const BufferIterator& iterator) const noexcept
|
||||||
{
|
{
|
||||||
return m_buffer != iterator.m_buffer or m_coord != iterator.m_coord;
|
return m_buffer != iterator.m_buffer or m_coord != iterator.m_coord;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool BufferIterator::operator<(const BufferIterator& iterator) const
|
inline bool BufferIterator::operator<(const BufferIterator& iterator) const noexcept
|
||||||
{
|
{
|
||||||
kak_assert(m_buffer == iterator.m_buffer);
|
kak_assert(m_buffer == iterator.m_buffer);
|
||||||
return (m_coord < iterator.m_coord);
|
return (m_coord < iterator.m_coord);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool BufferIterator::operator<=(const BufferIterator& iterator) const
|
inline bool BufferIterator::operator<=(const BufferIterator& iterator) const noexcept
|
||||||
{
|
{
|
||||||
kak_assert(m_buffer == iterator.m_buffer);
|
kak_assert(m_buffer == iterator.m_buffer);
|
||||||
return (m_coord <= iterator.m_coord);
|
return (m_coord <= iterator.m_coord);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool BufferIterator::operator>(const BufferIterator& iterator) const
|
inline bool BufferIterator::operator>(const BufferIterator& iterator) const noexcept
|
||||||
{
|
{
|
||||||
kak_assert(m_buffer == iterator.m_buffer);
|
kak_assert(m_buffer == iterator.m_buffer);
|
||||||
return (m_coord > iterator.m_coord);
|
return (m_coord > iterator.m_coord);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool BufferIterator::operator>=(const BufferIterator& iterator) const
|
inline bool BufferIterator::operator>=(const BufferIterator& iterator) const noexcept
|
||||||
{
|
{
|
||||||
kak_assert(m_buffer == iterator.m_buffer);
|
kak_assert(m_buffer == iterator.m_buffer);
|
||||||
return (m_coord >= iterator.m_coord);
|
return (m_coord >= iterator.m_coord);
|
||||||
}
|
}
|
||||||
|
|
||||||
[[gnu::always_inline]]
|
[[gnu::always_inline]]
|
||||||
inline const char& BufferIterator::operator*() const
|
inline const char& BufferIterator::operator*() const noexcept
|
||||||
{
|
{
|
||||||
return m_line[m_coord.column];
|
return m_line[m_coord.column];
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const char& BufferIterator::operator[](size_t n) const
|
inline const char& BufferIterator::operator[](size_t n) const noexcept
|
||||||
{
|
{
|
||||||
return m_buffer->byte_at(m_buffer->advance(m_coord, n));
|
return m_buffer->byte_at(m_buffer->advance(m_coord, n));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user