[Square] Initial implementation

This commit is contained in:
2022-12-18 17:58:43 +01:00
parent 4bf3f2cec4
commit 8613a92e2a
2 changed files with 50 additions and 46 deletions

View File

@@ -11,10 +11,9 @@ public:
using Coordinate = unsigned;
using Index = unsigned;
using Optional = std::optional<Square>;
static Optional fromCoordinates(Coordinate file, Coordinate rank);
static Optional fromIndex(Index index);
static Optional fromName(const std::string& name);
static Optional fromName(const std::string &name);
Coordinate file() const;
Coordinate rank() const;
@@ -32,12 +31,14 @@ public:
private:
Square(Index index);
Index mIndex;
};
std::ostream& operator<<(std::ostream& os, const Square& square);
std::ostream &operator<<(std::ostream &os, const Square &square);
// Necessary to support Square as the key in std::map.
bool operator<(const Square& lhs, const Square& rhs);
bool operator==(const Square& lhs, const Square& rhs);
bool operator<(const Square &lhs, const Square &rhs);
bool operator==(const Square &lhs, const Square &rhs);
#endif