diff --git a/moves_io.cpp b/moves_io.cpp index abe6520..7d78eb1 100644 --- a/moves_io.cpp +++ b/moves_io.cpp @@ -27,6 +27,7 @@ #include "position.h" #include "types.h" #include +#include #include #if defined(_CHESSLIB_ERROR_MODE_THROW) #define INVALID_ARG_IF(c, exception) \ @@ -174,10 +175,10 @@ template Move uciToMove(const _Position &pos, std /// @tparam T Piece enum type. /// @tparam P Position tag. /// @param pos The position. -/// @param san SAN string (e.g. "Nf3", "O-O"). +/// @param raw_san SAN string (e.g. "Nf3", "O-O"). /// @param remove_illegals If true, return Move::NO_MOVE instead of throwing. /// @return The parsed Move. -template Move parseSan(const _Position &pos, std::string_view san, bool remove_illegals) { +template Move parseSan(const _Position &pos, std::string_view raw_san, bool remove_illegals) { auto do_parse = [&](std::string_view input_san) -> Move { if (input_san.empty()) return Move::none(); @@ -404,17 +405,17 @@ template Move parseSan(const _Position &pos, std: }; if (remove_illegals) { - std::string trimmed_san(san); + std::string trimmed_san(raw_san); while (!trimmed_san.empty()) { Move attempt = do_parse(trimmed_san); if (attempt.is_ok()) return attempt; trimmed_san.pop_back(); } - INVALID_ARG_IF(trimmed_san.empty(), IllegalMoveException("illegal san: '" + std::string(san) + "' in " + pos.fen())); + INVALID_ARG_IF(trimmed_san.empty(), IllegalMoveException("illegal san: '" + std::string(raw_san) + "' in " + pos.fen())); return Move::none(); } else - return do_parse(san); + return do_parse(raw_san); } /// @brief Convert a Move to SAN or LAN (Long Algebraic Notation) string. template std::string moveToSan(const _Position &pos, Move move, bool long_, bool suffix) { diff --git a/moves_io.h b/moves_io.h index a9064f7..12b2bc4 100644 --- a/moves_io.h +++ b/moves_io.h @@ -83,16 +83,16 @@ template Move uciToMove(const _Position &p /// @tparam T Piece enum type. /// @tparam P Position tag. /// @param pos The position. -/// @param san SAN string (e.g. "Nf3", "O-O"). +/// @param raw_san SAN string (e.g. "Nf3", "O-O"). /// @param remove_illegals If true, return Move::NO_MOVE instead of throwing. /// @return The parsed Move. template -Move parseSan(const _Position &pos, std::string_view san, bool remove_illegals = false); +Move parseSan(const _Position &pos, std::string_view raw_san, bool remove_illegals = false); -/// @brief Alias for parseSan. +/// @copydoc parseSan template -Move parse_san(const _Position &pos, std::string_view san, bool remove_illegals = false) { - return parseSan(pos, san, remove_illegals); +inline Move parse_san(const _Position &pos, std::string_view raw_san, bool remove_illegals = false) { + return parseSan(pos, raw_san, remove_illegals); } /// @brief Convert a Move to SAN string for the given position. @@ -106,9 +106,9 @@ Move parse_san(const _Position &pos, std::string_view san, bool remove_ill template std::string moveToSan(const _Position &pos, Move move, bool long_ = false, bool suffix = true); -/// @brief Alias for moveToSan. +/// @copydoc moveToSan template -std::string move_to_san(const _Position &pos, Move move, bool long_ = false, bool suffix = true) { +inline std::string move_to_san(const _Position &pos, Move move, bool long_ = false, bool suffix = true) { return moveToSan(pos, move, long_, suffix); } } // namespace chess::uci diff --git a/position.h b/position.h index fb8be73..026fff1 100644 --- a/position.h +++ b/position.h @@ -314,7 +314,8 @@ template inline auto undo_move() -> std::conditional_t, void> { + template + inline auto undo_move() -> std::conditional_t, void> { return undoMove(); } @@ -343,7 +344,7 @@ template #include #include #include - /// @file types.h /// @brief Core chess type definitions: squares, pieces, colours, move encoding, and ValueList. #if defined(__clang__) || defined(__GNUC__)