make windows-compliant

- fix BS_thread_pool include error (pulls in windows.h, symbols were
redefined)
- remove all std::println uses :(, seems like mingw doesn't like those
- allow to disable backward from cmake
This commit is contained in:
2026-02-27 12:31:08 +01:00
parent 16df3b7d51
commit 85ed3a758a
11 changed files with 110 additions and 60 deletions

View File

@ -7,7 +7,7 @@
#include <cstddef>
#include <format>
#include <functional>
#include <print>
#include <iostream>
#include <string>
#include <vector>
@ -40,7 +40,7 @@ public:
: x(_x), y(_y), width(_width), height(_height), target(_target),
immovable(_immovable) {
if (_x < 0 || _x + _width >= 10 || _y < 0 || _y + _height >= 10) {
std::println("Block must fit in a 9x9 board!");
std::cout << std::format("Block must fit in a 9x9 board!") << std::endl;
exit(1);
}
}
@ -92,11 +92,12 @@ public:
}
if (_x < 0 || _x + width >= 10 || _y < 0 || _y + height >= 10) {
std::println("Block must fit in a 9x9 board!");
std::cout << std::format("Block must fit in a 9x9 board!") << std::endl;
exit(1);
}
if (block.length() != 2) {
std::println("Block representation must have length 2!");
std::cout << std::format("Block representation must have length 2!")
<< std::endl;
exit(1);
}
}
@ -186,12 +187,15 @@ public:
_height, _target_x, _target_y,
std::string(_width * _height * 2, '.'))) {
if (_width < 1 || _width > 9 || _height < 1 || _height > 9) {
std::println("State width/height must be in [1, 9]!");
std::cout << std::format("State width/height must be in [1, 9]!")
<< std::endl;
exit(1);
}
if (_target_x < 0 || _target_x >= 9 || _target_y < 0 || _target_y >= 9) {
if (_target_x != 9 && _target_y != 9) {
std::println("State target must be within the board bounds!");
std::cout << std::format(
"State target must be within the board bounds!")
<< std::endl;
exit(1);
}
}
@ -209,19 +213,23 @@ public:
target_y(std::stoi(_state.substr(4, 1))),
restricted(_state.substr(0, 1) == "R"), state(_state) {
if (width < 1 || width > 9 || height < 1 || height > 9) {
std::println("State width/height must be in [1, 9]!");
std::cout << std::format("State width/height must be in [1, 9]!")
<< std::endl;
exit(1);
}
if (target_x < 0 || target_x >= 9 || target_y < 0 || target_y >= 9) {
if (target_x != 9 && target_y != 9) {
std::println("State target must be within the board bounds!");
std::cout << std::format(
"State target must be within the board bounds!")
<< std::endl;
exit(1);
}
}
if (static_cast<int>(_state.length()) != width * height * 2 + prefix) {
std::println(
"State representation must have length width * height * 2 + {}!",
prefix);
std::cout << std::format("State representation must have length width * "
"height * 2 + {}!",
prefix)
<< std::endl;
exit(1);
}
}