Skip to content

Commit

Permalink
Unify type alias declarations
Browse files Browse the repository at this point in the history
The commit unifies the declaration of type aliases by replacing all
typedefs with corresponding using statements.

closing #4412

No functional change
  • Loading branch information
UniQP authored and vondele committed Feb 27, 2023
1 parent ff5a6f8 commit 564456a
Show file tree
Hide file tree
Showing 12 changed files with 39 additions and 39 deletions.
2 changes: 1 addition & 1 deletion src/material.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ struct Entry {
uint8_t factor[COLOR_NB];
};

typedef HashTable<Entry, 8192> Table;
using Table = HashTable<Entry, 8192>;

Entry* probe(const Position& pos);

Expand Down
12 changes: 6 additions & 6 deletions src/misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@
// the calls at compile time), try to load them at runtime. To do this we need
// first to define the corresponding function pointers.
extern "C" {
typedef bool(*fun1_t)(LOGICAL_PROCESSOR_RELATIONSHIP,
PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX, PDWORD);
typedef bool(*fun2_t)(USHORT, PGROUP_AFFINITY);
typedef bool(*fun3_t)(HANDLE, CONST GROUP_AFFINITY*, PGROUP_AFFINITY);
typedef bool(*fun4_t)(USHORT, PGROUP_AFFINITY, USHORT, PUSHORT);
typedef WORD(*fun5_t)();
using fun1_t = bool(*)(LOGICAL_PROCESSOR_RELATIONSHIP,
PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX, PDWORD);
using fun2_t = bool(*)(USHORT, PGROUP_AFFINITY);
using fun3_t = bool(*)(HANDLE, CONST GROUP_AFFINITY*, PGROUP_AFFINITY);
using fun4_t = bool(*)(USHORT, PGROUP_AFFINITY, USHORT, PUSHORT);
using fun5_t = WORD(*)();
}
#endif

Expand Down
4 changes: 2 additions & 2 deletions src/misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void dbg_stdev_of(int64_t value, int slot = 0);
void dbg_correl_of(int64_t value1, int64_t value2, int slot = 0);
void dbg_print();

typedef std::chrono::milliseconds::rep TimePoint; // A value in milliseconds
using TimePoint = std::chrono::milliseconds::rep; // A value in milliseconds
static_assert(sizeof(TimePoint) == sizeof(int64_t), "TimePoint should be 64 bits");
inline TimePoint now() {
return std::chrono::duration_cast<std::chrono::milliseconds>
Expand Down Expand Up @@ -165,7 +165,7 @@ class PRNG {

inline uint64_t mul_hi64(uint64_t a, uint64_t b) {
#if defined(__GNUC__) && defined(IS_64BIT)
__extension__ typedef unsigned __int128 uint128;
__extension__ using uint128 = unsigned __int128;
return ((uint128)a * (uint128)b) >> 64;
#else
uint64_t aL = (uint32_t)a, aH = a >> 32;
Expand Down
14 changes: 7 additions & 7 deletions src/movepick.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ class StatsEntry {
template <typename T, int D, int Size, int... Sizes>
struct Stats : public std::array<Stats<T, D, Sizes...>, Size>
{
typedef Stats<T, D, Size, Sizes...> stats;
using stats = Stats<T, D, Size, Sizes...>;

void fill(const T& v) {

// For standard-layout 'this' points to first struct member
assert(std::is_standard_layout<stats>::value);

typedef StatsEntry<T, D> entry;
using entry = StatsEntry<T, D>;
entry* p = reinterpret_cast<entry*>(this);
std::fill(p, p + sizeof(*this) / sizeof(entry), v);
}
Expand All @@ -87,23 +87,23 @@ enum StatsType { NoCaptures, Captures };
/// ordering decisions. It uses 2 tables (one for each color) indexed by
/// the move's from and to squares, see www.chessprogramming.org/Butterfly_Boards
/// (~11 elo)
typedef Stats<int16_t, 7183, COLOR_NB, int(SQUARE_NB) * int(SQUARE_NB)> ButterflyHistory;
using ButterflyHistory = Stats<int16_t, 7183, COLOR_NB, int(SQUARE_NB) * int(SQUARE_NB)>;

/// CounterMoveHistory stores counter moves indexed by [piece][to] of the previous
/// move, see www.chessprogramming.org/Countermove_Heuristic
typedef Stats<Move, NOT_USED, PIECE_NB, SQUARE_NB> CounterMoveHistory;
using CounterMoveHistory = Stats<Move, NOT_USED, PIECE_NB, SQUARE_NB>;

/// CapturePieceToHistory is addressed by a move's [piece][to][captured piece type]
typedef Stats<int16_t, 10692, PIECE_NB, SQUARE_NB, PIECE_TYPE_NB> CapturePieceToHistory;
using CapturePieceToHistory = Stats<int16_t, 10692, PIECE_NB, SQUARE_NB, PIECE_TYPE_NB>;

/// PieceToHistory is like ButterflyHistory but is addressed by a move's [piece][to]
typedef Stats<int16_t, 29952, PIECE_NB, SQUARE_NB> PieceToHistory;
using PieceToHistory = Stats<int16_t, 29952, PIECE_NB, SQUARE_NB>;

/// ContinuationHistory is the combined history of a given pair of moves, usually
/// the current one given a previous one. The nested history table is based on
/// PieceToHistory instead of ButterflyBoards.
/// (~63 elo)
typedef Stats<PieceToHistory, NOT_USED, PIECE_NB, SQUARE_NB> ContinuationHistory;
using ContinuationHistory = Stats<PieceToHistory, NOT_USED, PIECE_NB, SQUARE_NB>;


/// MovePicker class is used to pick one pseudo-legal move at a time from the
Expand Down
20 changes: 10 additions & 10 deletions src/nnue/nnue_feature_transformer.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ namespace Stockfish::Eval::NNUE {
"Per feature PSQT values cannot be processed at granularity lower than 8 at a time.");

#ifdef USE_AVX512
typedef __m512i vec_t;
typedef __m256i psqt_vec_t;
using vec_t = __m512i;
using psqt_vec_t = __m256i;
#define vec_load(a) _mm512_load_si512(a)
#define vec_store(a,b) _mm512_store_si512(a,b)
#define vec_add_16(a,b) _mm512_add_epi16(a,b)
Expand All @@ -66,8 +66,8 @@ namespace Stockfish::Eval::NNUE {
#define MaxChunkSize 64

#elif USE_AVX2
typedef __m256i vec_t;
typedef __m256i psqt_vec_t;
using vec_t = __m256i;
using psqt_vec_t = __m256i;
#define vec_load(a) _mm256_load_si256(a)
#define vec_store(a,b) _mm256_store_si256(a,b)
#define vec_add_16(a,b) _mm256_add_epi16(a,b)
Expand All @@ -90,8 +90,8 @@ namespace Stockfish::Eval::NNUE {
#define MaxChunkSize 32

#elif USE_SSE2
typedef __m128i vec_t;
typedef __m128i psqt_vec_t;
using vec_t = __m128i;
using psqt_vec_t = __m128i;
#define vec_load(a) (*(a))
#define vec_store(a,b) *(a)=(b)
#define vec_add_16(a,b) _mm_add_epi16(a,b)
Expand All @@ -111,8 +111,8 @@ namespace Stockfish::Eval::NNUE {
#define MaxChunkSize 16

#elif USE_MMX
typedef __m64 vec_t;
typedef __m64 psqt_vec_t;
using vec_t = __m64;
using psqt_vec_t = __m64;
#define vec_load(a) (*(a))
#define vec_store(a,b) *(a)=(b)
#define vec_add_16(a,b) _mm_add_pi16(a,b)
Expand All @@ -139,8 +139,8 @@ namespace Stockfish::Eval::NNUE {
#define MaxChunkSize 8

#elif USE_NEON
typedef int16x8_t vec_t;
typedef int32x4_t psqt_vec_t;
using vec_t = int16x8_t;
using psqt_vec_t = int32x4_t;
#define vec_load(a) (*(a))
#define vec_store(a,b) *(a)=(b)
#define vec_add_16(a,b) vaddq_s16(a,b)
Expand Down
2 changes: 1 addition & 1 deletion src/pawns.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ struct Entry {
int blockedCount;
};

typedef HashTable<Entry, 131072> Table;
using Table = HashTable<Entry, 131072>;

Entry* probe(const Position& pos);

Expand Down
2 changes: 1 addition & 1 deletion src/position.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ struct StateInfo {
/// start position to the position just before the search starts). Needed by
/// 'draw by repetition' detection. Use a std::deque because pointers to
/// elements are not invalidated upon list resizing.
typedef std::unique_ptr<std::deque<StateInfo>> StateListPtr;
using StateListPtr = std::unique_ptr<std::deque<StateInfo>>;


/// Position class stores information regarding the board representation as
Expand Down
2 changes: 1 addition & 1 deletion src/search.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ struct RootMove {
std::vector<Move> pv;
};

typedef std::vector<RootMove> RootMoves;
using RootMoves = std::vector<RootMove>;


/// LimitsType struct stores information sent by GUI about available time to
Expand Down
4 changes: 2 additions & 2 deletions src/syzygy/tbprobe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ struct SparseEntry {

static_assert(sizeof(SparseEntry) == 6, "SparseEntry must be 6 bytes");

typedef uint16_t Sym; // Huffman symbol
using Sym = uint16_t; // Huffman symbol

struct LR {
enum Side { Left, Right };
Expand Down Expand Up @@ -327,7 +327,7 @@ struct PairsData {
// first access, when the corresponding file is memory mapped.
template<TBType Type>
struct TBTable {
typedef typename std::conditional<Type == WDL, WDLScore, int>::type Ret;
using Ret = typename std::conditional<Type == WDL, WDLScore, int>::type;

static constexpr int Sides = Type == WDL ? 2 : 1;

Expand Down
6 changes: 3 additions & 3 deletions src/tune.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@

namespace Stockfish {

typedef std::pair<int, int> Range; // Option's min-max values
typedef Range (RangeFun) (int);
using Range = std::pair<int, int>; // Option's min-max values
using RangeFun = Range (int);

// Default Range function, to calculate Option's min-max values
inline Range default_range(int v) {
Expand Down Expand Up @@ -75,7 +75,7 @@ struct SetRange {

class Tune {

typedef void (PostUpdate) (); // Post-update function
using PostUpdate = void (); // Post-update function

Tune() { read_results(); }
Tune(const Tune&) = delete;
Expand Down
6 changes: 3 additions & 3 deletions src/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ constexpr bool Is64Bit = true;
constexpr bool Is64Bit = false;
#endif

typedef uint64_t Key;
typedef uint64_t Bitboard;
using Key = uint64_t;
using Bitboard = uint64_t;

constexpr int MAX_MOVES = 256;
constexpr int MAX_PLY = 246;
Expand Down Expand Up @@ -218,7 +218,7 @@ constexpr Value PieceValue[PHASE_NB][PIECE_NB] = {
VALUE_ZERO, PawnValueEg, KnightValueEg, BishopValueEg, RookValueEg, QueenValueEg, VALUE_ZERO, VALUE_ZERO }
};

typedef int Depth;
using Depth = int;

enum : int {
DEPTH_QS_CHECKS = 0,
Expand Down
4 changes: 2 additions & 2 deletions src/uci.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ struct CaseInsensitiveLess {
};

/// The options container is defined as a std::map
typedef std::map<std::string, Option, CaseInsensitiveLess> OptionsMap;
using OptionsMap = std::map<std::string, Option, CaseInsensitiveLess>;

/// The Option class implements each option as specified by the UCI protocol
class Option {

typedef void (*OnChange)(const Option&);
using OnChange = void (*)(const Option&);

public:
Option(OnChange = nullptr);
Expand Down

0 comments on commit 564456a

Please sign in to comment.