Skip to content

Commit

Permalink
[SUTK] Corrected relational operator overloads of SUTK::CursorPosition
Browse files Browse the repository at this point in the history
  • Loading branch information
ravi688 committed Aug 17, 2024
1 parent 5255393 commit ceb97c7
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions sutk/include/sutk/Text.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,21 +160,25 @@ namespace SUTK
CursorPosition(T line, T col = 0) noexcept : m_line(line), m_col(col) { }
CursorPosition(const CursorPosition&) = default;
CursorPosition& operator=(const CursorPosition&) = default;
bool operator==(const CursorPosition& rhs) const noexcept
{
return (m_line == rhs.m_line) && (m_col == rhs.m_col);
}
bool operator <(const CursorPosition& rhs) const noexcept
{
return (m_line < rhs.m_line) && (m_col < rhs.m_col);
return (m_line < rhs.m_line) || ((m_line == rhs.m_line) && (m_col < rhs.m_col));
}
bool operator <=(const CursorPosition& rhs) const noexcept
{
return (m_line <= rhs.m_line) && (m_col <= rhs.m_col);
return (m_line < rhs.m_line) || ((m_line == rhs.m_line) && (m_col <= rhs.m_col));
}
bool operator >(const CursorPosition& rhs) const noexcept
{
return (m_line > rhs.m_line) && (m_col > rhs.m_col);
return (m_line > rhs.m_line) || ((m_line == rhs.m_line) && (m_col > rhs.m_col));
}
bool operator >=(const CursorPosition& rhs) const noexcept
{
return (m_line >= rhs.m_line) && (m_col >= rhs.m_col);
return (m_line > rhs.m_line) || ((m_line == rhs.m_line) && (m_col >= rhs.m_col));
}

void moveToNextLine(const T& max = std::numeric_limits<T>::max()) noexcept { if(m_line < max) m_line += 1; }
Expand Down

0 comments on commit ceb97c7

Please sign in to comment.