X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fsquare.h;h=a4dde9cb6dc35300a366d5a9d9493c2d33a4c3d3;hb=61c03b9d22de0c1ccf0c60af4e223775d4b3f7cc;hp=8de3f55c56016269b0469277053b9626825e1a84;hpb=4ce08482c3b0685691162bfc9115ccc7656674b4;p=stockfish diff --git a/src/square.h b/src/square.h index 8de3f55c..a4dde9cb 100644 --- a/src/square.h +++ b/src/square.h @@ -64,6 +64,11 @@ enum SquareDelta { DELTA_NN = 020, DELTA_NNE = 021 }; +ENABLE_OPERATORS_ON(Square); +ENABLE_OPERATORS_ON(File); +ENABLE_OPERATORS_ON(Rank); +ENABLE_OPERATORS_ON(SquareDelta); + //// //// Constants @@ -77,20 +82,10 @@ const int FlopMask = 07; //// Inline functions //// -inline Square operator+ (Square x, int i) { return Square(int(x) + i); } -inline void operator++ (Square &x, int) { x = Square(int(x) + 1); } -inline void operator+= (Square &x, int i) { x = Square(int(x) + i); } -inline Square operator- (Square x, int i) { return Square(int(x) - i); } -inline void operator-- (Square &x, int) { x = Square(int(x) - 1); } -inline void operator-= (Square &x, int i) { x = Square(int(x) - i); } -inline Square operator+ (Square x, SquareDelta i) { return Square(int(x) + i); } -inline void operator+= (Square &x, SquareDelta i) { x = Square(int(x) + i); } -inline Square operator- (Square x, SquareDelta i) { return Square(int(x) - i); } -inline void operator-= (Square &x, SquareDelta i) { x = Square(int(x) - i); } - -inline SquareDelta operator- (Square x, Square y) { - return SquareDelta(int(x) - int(y)); -} +inline Square operator+ (Square x, SquareDelta i) { return x + Square(i); } +inline void operator+= (Square& x, SquareDelta i) { x = x + Square(i); } +inline Square operator- (Square x, SquareDelta i) { return x - Square(i); } +inline void operator-= (Square& x, SquareDelta i) { x = x - Square(i); } inline Square make_square(File f, Rank r) { return Square(int(f) | (int(r) << 3)); @@ -165,10 +160,6 @@ inline char rank_to_char(Rank r) { return char(r - RANK_1 + int('1')); } -inline Square square_from_string(const std::string& str) { - return make_square(file_from_char(str[0]), rank_from_char(str[1])); -} - inline const std::string square_to_string(Square s) { return std::string(1, file_to_char(square_file(s))) + std::string(1, rank_to_char(square_rank(s)));