Introduce variadic make_bitboard()

Adds a helper function to make a bitboard from a list of squares.

No functional change
This commit is contained in:
Chris Cain
2018-03-06 01:32:16 +01:00
committed by Stéphane Nicolet
parent 450f04969c
commit 3192b09fe0
2 changed files with 18 additions and 6 deletions

View File

@@ -150,7 +150,17 @@ inline Bitboard file_bb(Square s) {
}
/// shift() moves a bitboard one step along direction D. Mainly for pawns
/// make_bitboard() returns a bitboard from a list of squares
constexpr Bitboard make_bitboard() { return 0; }
template<typename ...Squares>
constexpr Bitboard make_bitboard(Square s, Squares... squares) {
return (1ULL << s) | make_bitboard(squares...);
}
/// shift() moves a bitboard one step along direction D (mainly for pawns)
template<Direction D>
constexpr Bitboard shift(Bitboard b) {