enum entry {empty, nought, cross};
class board {
public:
board();
// Returns a copy of the entry in the given row and column
entry operator()(int row, int col) const;
// Returns a reference to the entry in the given row and column
entry& operator()(int row, int col);
// being & end for iteration over cells in COLUMN-MAJOR order
auto begin() const { return array_.begin(); }
auto end() const { return array_.end(); }
private:
std::array<entry, 9> array_;
};
The entry to the array is with a row and column integers.
What would be the most efficient method be for asserting if two integers (row,col) are indeed valid?
For example;
1,1 - valid
-1,1 - invalid
3,4 - invalid
3,3 - valid
for the following layout