+
+/// pop_1st_bit() finds and clears the least significant nonzero bit in a
+/// nonzero bitboard. If template parameter is true an intrinsic is called,
+/// otherwise we fallback on a software implementation.
+
+template<bool UseIntrinsic>
+inline Square pop_1st_bit(Bitboard *b) {
+
+ return pop_1st_bit(b);
+}
+
+template<>
+inline Square pop_1st_bit<true>(Bitboard *b) {
+
+ unsigned long idx;
+ Bitboard bb = *b;
+ BITSCAN_INTRINSIC(&idx, bb);
+ *b &= (bb - 1);
+ return Square(idx);
+}
+