Mark all compile-time constants as constexpr.

To more clearly distinguish them from "const" local variables, this patch
defines compile-time local constants as constexpr. This is consistent with
the definition of PvNode as constexpr in search() and qsearch(). It also
makes the code more robust, since the compiler will now check that those
constants are indeed compile-time constants.

We can go even one step further and define all the evaluation and search
compile-time constants as constexpr.

In generate_castling() I replaced "K" with "step", since K was incorrectly
capitalised (in the Chess960 case).

In timeman.cpp I had to make the non-local constants MaxRatio and StealRatio
constepxr, since otherwise gcc would complain when calculating TMaxRatio and
TStealRatio. (Strangely, I did not have to make Is64Bit constexpr even though
it is used in ucioption.cpp in the calculation of constexpr MaxHashMB.)

I have renamed PieceCount to pieceCount in material.h, since the values of
the array are not compile-time constants.

Some compile-time constants in tbprobe.cpp were overlooked. Sides and MaxFile
are not compile-time constants, so were renamed to sides and maxFile.

Non-functional change.
This commit is contained in:
Ronald de Man
2018-03-18 23:38:58 +01:00
committed by Stéphane Nicolet
parent 350dff4464
commit 759b3c79cf
17 changed files with 164 additions and 164 deletions

View File

@@ -80,28 +80,28 @@
#endif
#ifdef USE_POPCNT
const bool HasPopCnt = true;
constexpr bool HasPopCnt = true;
#else
const bool HasPopCnt = false;
constexpr bool HasPopCnt = false;
#endif
#ifdef USE_PEXT
const bool HasPext = true;
constexpr bool HasPext = true;
#else
const bool HasPext = false;
constexpr bool HasPext = false;
#endif
#ifdef IS_64BIT
const bool Is64Bit = true;
constexpr bool Is64Bit = true;
#else
const bool Is64Bit = false;
constexpr bool Is64Bit = false;
#endif
typedef uint64_t Key;
typedef uint64_t Bitboard;
const int MAX_MOVES = 256;
const int MAX_PLY = 128;
constexpr int MAX_MOVES = 256;
constexpr int MAX_PLY = 128;
/// A move needs 16 bits to be stored
///