diff options
Diffstat (limited to 'src/location.hh')
| -rw-r--r-- | src/location.hh | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/location.hh b/src/location.hh new file mode 100644 index 0000000..1a210cb --- /dev/null +++ b/src/location.hh @@ -0,0 +1,31 @@ +#ifndef LOCATION_HH +#define LOCATION_HH + +#include <compare> +#include <cstdint> +#include <iosfwd> + +namespace src { + +struct Location { + uint64_t line; + uint16_t column; + + constexpr Location() : line(0), column(0) {} + + Location(uint64_t line, uint16_t column) : line(line), column(column) {} + + [[nodiscard]] + std::strong_ordering operator<=>(Location const& loc) const { + auto ret = line <=> loc.line; + if (ret == std::strong_ordering::equal) + return column <=> loc.column; + return ret; + } +}; + +std::ostream& operator<<(std::ostream& out, Location const& loc); + +} // namespace src + +#endif // LOCATION_HH |
