added validity check when creating coords from index
This commit is contained in:
parent
e5819ee83b
commit
5f79b81ce4
@ -17,7 +17,10 @@ struct Coords {
|
||||
return this->y * 8 + this->x;
|
||||
}
|
||||
|
||||
static Coords from_index(int idx) {
|
||||
static Coords from_index(int idx, const char* yes = __builtin_FUNCTION()) {
|
||||
// std::cout << yes << std::endl;
|
||||
if (idx < 0 || idx > 63)
|
||||
throw std::invalid_argument("The index is outside the board...");
|
||||
return {idx % 8, idx / 8};
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user