X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fbitboard.h;fp=src%2Fbitboard.h;h=aa29abf21adc7a98565fac2346dfbe38a13cde0f;hp=6907f184e5429c12866d504e3e69a6ca49979658;hb=c8589903777b6e0289640b43fae966ded442af48;hpb=d1f76ebcd8cc475d08b468efe4b467e014efef14 diff --git a/src/bitboard.h b/src/bitboard.h index 6907f184..aa29abf2 100644 --- a/src/bitboard.h +++ b/src/bitboard.h @@ -249,6 +249,9 @@ template inline int distance(T2 x, T2 y); template<> inline int distance(Square x, Square y) { return distance(file_of(x), file_of(y)); } template<> inline int distance(Square x, Square y) { return distance(rank_of(x), rank_of(y)); } +template constexpr const T& clamp(const T& v, const T& lo, const T& hi) { + return v < lo ? lo : v > hi ? hi : v; +} /// attacks_bb() returns a bitboard representing all the squares attacked by a /// piece of type Pt (bishop or rook) placed on 's'.