]> git.sesse.net Git - stockfish/blobdiff - src/bitboard.h
Introduce least_significant_square_bb()
[stockfish] / src / bitboard.h
index e14fe0df7d30c2d3bec0d6d83e2ee833fa61c0c9..1b6af3ead1afedbaba67526b32cd3f6762ffed4f 100644 (file)
@@ -414,6 +414,13 @@ inline Square msb(Bitboard b) {
 
 #endif
 
+/// least_significant_square_bb() returns the bitboard of the least significant
+/// square of a non-zero bitboard. It is equivalent to square_bb(lsb(bb)).
+
+inline Bitboard least_significant_square_bb(Bitboard b) {
+  assert(b);
+  return b & -b;
+}
 
 /// pop_lsb() finds and clears the least significant bit in a non-zero bitboard