1
0
Fork 0

Explicitly defaulted and deleted members

Better than a bit obscure implicit ones.

No functional change.
pull/268/head
Marco Costalba 2015-01-21 13:18:19 +01:00
parent 2ca2c3f35b
commit 96e36a7897
6 changed files with 12 additions and 17 deletions

View File

@ -45,11 +45,10 @@ namespace Time {
template<class Entry, int Size>
struct HashTable {
HashTable() : table(Size, Entry()) {}
Entry* operator[](Key key) { return &table[(uint32_t)key & (Size - 1)]; }
private:
std::vector<Entry> table;
std::vector<Entry> table = std::vector<Entry>(Size);
};

View File

@ -80,10 +80,10 @@ typedef Stats<false, std::pair<Move, Move> > MovesStats;
/// to get a cut-off first.
class MovePicker {
MovePicker& operator=(const MovePicker&); // Silence a warning under MSVC
public:
MovePicker(const MovePicker&) = delete;
MovePicker& operator=(const MovePicker&) = delete;
MovePicker(const Position&, Move, Depth, const HistoryStats&, Square);
MovePicker(const Position&, Move, const HistoryStats&, PieceType);
MovePicker(const Position&, Move, Depth, const HistoryStats&, Move*, Move*, Search::Stack*);

View File

@ -82,12 +82,11 @@ class Position {
friend std::ostream& operator<<(std::ostream&, const Position&);
Position(const Position&); // Disable the default copy constructor
public:
static void init();
Position() {} // To define the global object RootPos
Position() = default; // To define the global object RootPos
Position(const Position&) = delete;
Position(const Position& pos, Thread* th) { *this = pos; thisThread = th; }
Position(const std::string& f, bool c960, Thread* th) { set(f, c960, th); }
Position& operator=(const Position&); // To assign RootPos from UCI

View File

@ -73,8 +73,7 @@ struct SplitPoint {
struct ThreadBase {
ThreadBase() : exit(false) {}
virtual ~ThreadBase() {}
virtual ~ThreadBase() = default;
virtual void idle_loop() = 0;
void notify_one();
void wait_for(volatile const bool& b);
@ -82,7 +81,7 @@ struct ThreadBase {
std::thread nativeThread;
std::mutex mutex;
std::condition_variable sleepCondition;
volatile bool exit;
volatile bool exit = false;
};
@ -118,19 +117,17 @@ struct Thread : public ThreadBase {
/// special threads: the main one and the recurring timer.
struct MainThread : public Thread {
MainThread() : thinking(true) {} // Avoid a race with start_thinking()
virtual void idle_loop();
volatile bool thinking;
volatile bool thinking = true; // Avoid a race with start_thinking()
};
struct TimerThread : public ThreadBase {
static const int Resolution = 5; // Millisec between two check_time() calls
TimerThread() : run(false) {}
virtual void idle_loop();
bool run;
bool run = false;
};

View File

@ -32,8 +32,6 @@ TranspositionTable TT; // Our global transposition table
void TranspositionTable::resize(size_t mbSize) {
assert(sizeof(Cluster) == CacheLineSize / 2);
size_t newClusterCount = size_t(1) << msb((mbSize * 1024 * 1024) / sizeof(Cluster));
if (newClusterCount == clusterCount)

View File

@ -81,6 +81,8 @@ class TranspositionTable {
char padding[2]; // Align to the cache line size
};
static_assert(sizeof(Cluster) == CacheLineSize / 2, "Cluster size incorrect");
public:
~TranspositionTable() { free(mem); }
void new_search() { generation8 += 4; } // Lower 2 bits are used by Bound