+ Bitboard threatened, threatenedByPawn, threatenedByMinor, threatenedByRook;
+ if constexpr (Type == QUIETS)
+ {
+ // squares threatened by pawns
+ threatenedByPawn = pos.side_to_move() == WHITE ? threatsByPawn<BLACK>(pos) : threatsByPawn<WHITE>(pos);
+ // squares threatened by minors or pawns
+ threatenedByMinor = pos.side_to_move() == WHITE ? threatsByMinor<BLACK>(pos) : threatsByMinor<WHITE>(pos);
+ threatenedByMinor |= threatenedByPawn;
+ // squares threatened by rooks, minors or pawns
+ threatenedByRook = pos.side_to_move() == WHITE ? threatsByRook<BLACK>(pos) : threatsByRook<WHITE>(pos);
+ threatenedByRook |= threatenedByMinor;
+
+ // pieces threatened by pieces of lesser material value
+ threatened = pos.side_to_move() == WHITE ? ((pos.pieces(WHITE, QUEEN) & threatenedByRook) |
+ (pos.pieces(WHITE, ROOK) & threatenedByMinor) |
+ (pos.pieces(WHITE, KNIGHT, BISHOP) & threatenedByPawn))
+ : ((pos.pieces(BLACK, QUEEN) & threatenedByRook) |
+ (pos.pieces(BLACK, ROOK) & threatenedByMinor) |
+ (pos.pieces(BLACK, KNIGHT, BISHOP) & threatenedByPawn));
+ }
+ else
+ {
+ // Silence unused variable warning
+ (void) threatened;
+ (void) threatenedByPawn;
+ (void) threatenedByMinor;
+ (void) threatenedByRook;
+ }