This commit is contained in:
Calcitem 2021-11-06 23:07:43 +08:00
parent d65b3ea523
commit 207c4fc412
No known key found for this signature in database
GPG Key ID: F67E4F8CB7B5EED2
3 changed files with 13 additions and 13 deletions

View File

@ -48,7 +48,7 @@ const std::string Bitboards::pretty(Bitboard b)
void Bitboards::init() noexcept
{
for (unsigned i = 0; i < (1 << 16); ++i)
PopCnt16[i] = (uint8_t)std::bitset<16>(i).count();
PopCnt16[i] = static_cast<uint8_t>(std::bitset<16>(i).count());
for (Square s = SQ_BEGIN; s < SQ_END; ++s)
SquareBB[s] = (1UL << s);

View File

@ -156,7 +156,7 @@ inline int popcount(Bitboard b) noexcept
#elif defined(_MSC_VER) || defined(__INTEL_COMPILER)
return (int)_mm_popcnt_u32(b);
return static_cast<int>(_mm_popcnt_u32(b));
#else // Assumed gcc or compatible compiler

View File

@ -420,7 +420,7 @@ enum Rank : int {
inline T& operator+=(T& d1, int d2) { return d1 = d1 + d2; } \
inline T& operator-=(T& d1, int d2) { return d1 = d1 - d2; }
#define ENABLE_INCR_OPERATORS_ON(T) \
#define ENABLE_INCR_OPERATORS_ON(T) \
inline T& operator++(T& d) noexcept { return d = T(int(d) + 1); } \
inline T& operator--(T& d) noexcept { return d = T(int(d) - 1); }
@ -448,17 +448,17 @@ ENABLE_INCR_OPERATORS_ON(MoveDirection)
constexpr Color operator~(Color c)
{
return Color(c ^ 3); // Toggle color
return static_cast<Color>(c ^ 3); // Toggle color
}
constexpr Square make_square(File f, Rank r)
{
return Square((f << 3) + r - 1);
return static_cast<Square>((f << 3) + r - 1);
}
constexpr Piece make_piece(Color c)
{
return Piece(c << 4);
return static_cast<Piece>(c << 4);
}
constexpr Piece make_piece(Color c, PieceType pt)
@ -476,7 +476,7 @@ constexpr Piece make_piece(Color c, PieceType pt)
constexpr Color color_of(Piece pc)
{
return Color(pc >> 4);
return static_cast<Color>(pc >> 4);
}
constexpr PieceType type_of(Piece pc)
@ -503,7 +503,7 @@ constexpr bool is_ok(Square s)
constexpr File file_of(Square s)
{
return File(s >> 3);
return static_cast<File>(s >> 3);
}
constexpr Rank rank_of(Square s)
@ -514,7 +514,7 @@ constexpr Rank rank_of(Square s)
constexpr Square from_sq(Move m)
{
if (m < 0)
m = (Move)-m;
m = static_cast<Move>(-m);
return static_cast<Square>(m >> 8);
}
@ -522,9 +522,9 @@ constexpr Square from_sq(Move m)
constexpr Square to_sq(Move m)
{
if (m < 0)
m = (Move)-m;
m = static_cast<Move>(-m);
return Square(m & 0x00FF);
return static_cast<Square>(m & 0x00FF);
}
constexpr MoveType type_of(Move m)
@ -540,7 +540,7 @@ constexpr MoveType type_of(Move m)
constexpr Move make_move(Square from, Square to)
{
return Move((from << 8) + to);
return static_cast<Move>((from << 8) + to);
}
constexpr Move reverse_move(Move m)
@ -556,7 +556,7 @@ constexpr bool is_ok(Move m)
/// Based on a congruential pseudo random number generator
constexpr Key make_key(uint64_t seed)
{
return Key(seed * 6364136223846793005ULL + 1442695040888963407ULL);
return static_cast<Key>(seed * 6364136223846793005ULL + 1442695040888963407ULL);
}
#endif // #ifndef TYPES_H_INCLUDED