]> git.sesse.net Git - stockfish/commitdiff
Explicitly defaulted and deleted members
authorMarco Costalba <mcostalba@gmail.com>
Wed, 21 Jan 2015 12:18:19 +0000 (13:18 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Wed, 21 Jan 2015 12:18:19 +0000 (13:18 +0100)
Better than a bit obscure implicit ones.

No functional change.

src/misc.h
src/movepick.h
src/position.h
src/thread.h
src/tt.cpp
src/tt.h

index 9241834f3ea5bdcec135fe5bdd89436e33bc089e..e3fb6435471510bb80a91304bc0b322fec4ff7ca 100644 (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);
 };
 
 
index a7b25a924b47bd04383c9b98fb96e78c272f3d71..9482a89c491f7fa792771e88e52a9a5c3a0a3879 100644 (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*);
index 86acd20d0eb7a174b779147f8e992dce9ff4a7c5..0bb7b0b99ada88507cecd6f6f0518031c4e5c7a5 100644 (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
index bf16ca17f36448fdbd55eb5dba7758b5d9ae8aa4..3f902dc17b794a35250f87759e932dd9f0607bd4 100644 (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;
 };
 
 
index 66113ee8f2c4969bbe76e1cb2e3aa5e88e8c082f..bb49a824519a52b97828b1a6055d2e12cc8f198b 100644 (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)
index 4df015c07cbc34c5f847f4a91202b64b79a90b3f..14f820d0cb6677637615f7d21b312514ed2d26fe 100644 (file)
--- a/src/tt.h
+++ b/src/tt.h
@@ -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