Defined in header <cparse/Cursor.hh>

bool operator==( Cursor const& other ) const;

Compares two cursors for equality. Two cursors compare equal if their filename pointers refer to the same string, their line numbers match, and their column numbers match.

Parameters

ParameterDescription
otherThe cursor to compare against.

Return value

true if the two cursors have the same filename pointer, line number and column number; false otherwise.

Exceptions

Does not throw. Not marked noexcept explicitly but the body performs only pointer and integer comparisons.

Notes

The stored position (tellg() result), stream state and newLinePassed internal flag are not part of the comparison. Two cursors that agree on file/line/column but have different stored positions still compare equal. In practice this matches how grammars use the comparison — for cheap "am I still where I was?" checks after a look-ahead that may or may not have consumed anything.

Filename comparison is by pointer identity, not string content. Two cursors constructed from separate strings both spelled "input.txt" do not compare equal. In practice this is exactly what you want: cursors within the same parse share the filename pointer, and cursors from different files that happen to share a name should not be confused.

See also