+template<PieceType Pt>
+inline Bitboard Position::attacks_by(Color c) const {
+
+ if constexpr (Pt == PAWN)
+ return c == WHITE ? pawn_attacks_bb<WHITE>(pieces(WHITE, PAWN))
+ : pawn_attacks_bb<BLACK>(pieces(BLACK, PAWN));
+ else
+ {
+ Bitboard threats = 0;
+ Bitboard attackers = pieces(c, Pt);
+ while (attackers)
+ threats |= attacks_bb<Pt>(pop_lsb(attackers), pieces());
+ return threats;
+ }
+}
+