X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fbitboard.h;h=6f3a0048226eb620e6e9c07d9c4185145ad27b68;hp=7a39a5009c5571ccf0ef68b5d90792acc353de9b;hb=553655eb073cdd59c726dd77fcf368d499029467;hpb=7b4b65d7a95b3c8b40a11fe5b3efe959d5129008 diff --git a/src/bitboard.h b/src/bitboard.h index 7a39a500..6f3a0048 100644 --- a/src/bitboard.h +++ b/src/bitboard.h @@ -57,11 +57,19 @@ inline Bitboard operator&(Bitboard b, Square s) { } inline Bitboard& operator|=(Bitboard& b, Square s) { - return b |= SquareBB[s], b; + return b |= SquareBB[s]; } inline Bitboard& operator^=(Bitboard& b, Square s) { - return b ^= SquareBB[s], b; + return b ^= SquareBB[s]; +} + +inline Bitboard operator|(Bitboard b, Square s) { + return b | SquareBB[s]; +} + +inline Bitboard operator^(Bitboard b, Square s) { + return b ^ SquareBB[s]; } @@ -199,6 +207,14 @@ inline Bitboard same_color_squares(Square s) { } +/// single_bit() returns true if in the 'b' bitboard is set a single bit (or if +/// b == 0). + +inline bool single_bit(Bitboard b) { + return !(b & (b - 1)); +} + + /// first_1() finds the least significant nonzero bit in a nonzero bitboard. /// pop_1st_bit() finds and clears the least significant nonzero bit in a /// nonzero bitboard.