From b6833409d10e58ffc41ee37f3608af99a2bd7d26 Mon Sep 17 00:00:00 2001 From: winapiadmin <138602885+winapiadmin@users.noreply.github.com> Date: Sat, 20 Jun 2026 08:11:35 +0700 Subject: [PATCH 1/2] shadowed variables, as well as missing headers [verified using my own STL] --- moves_io.cpp | 9 +++++---- moves_io.h | 4 ++-- types.h | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/moves_io.cpp b/moves_io.cpp index abe6520..e1fd8b0 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,7 +405,7 @@ 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()) @@ -414,7 +415,7 @@ template Move parseSan(const _Position &pos, std: INVALID_ARG_IF(trimmed_san.empty(), IllegalMoveException("illegal san: '" + std::string(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..21b8b71 100644 --- a/moves_io.h +++ b/moves_io.h @@ -83,11 +83,11 @@ 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. template diff --git a/types.h b/types.h index f35673c..4d21bb4 100644 --- a/types.h +++ b/types.h @@ -23,10 +23,10 @@ #pragma once #include "fwd_decl.h" +#include #include #include #include - /// @file types.h /// @brief Core chess type definitions: squares, pieces, colours, move encoding, and ValueList. #if defined(__clang__) || defined(__GNUC__) From 945fe9f83ef5a677e92d32ce9d3ba2f6750a720a Mon Sep 17 00:00:00 2001 From: winapiadmin <138602885+winapiadmin@users.noreply.github.com> Date: Mon, 22 Jun 2026 09:51:31 +0700 Subject: [PATCH 2/2] some more api --- moves_io.cpp | 2 +- moves_io.h | 10 +++++----- position.h | 8 ++++++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/moves_io.cpp b/moves_io.cpp index e1fd8b0..7d78eb1 100644 --- a/moves_io.cpp +++ b/moves_io.cpp @@ -412,7 +412,7 @@ template Move parseSan(const _Position &pos, std: 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(raw_san); diff --git a/moves_io.h b/moves_io.h index 21b8b71..12b2bc4 100644 --- a/moves_io.h +++ b/moves_io.h @@ -89,10 +89,10 @@ template Move uciToMove(const _Position &p template 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