diff --git a/src/coins.h b/src/coins.h --- a/src/coins.h +++ b/src/coins.h @@ -204,6 +204,12 @@ public: CCoinsViewCache(CCoinsView *baseIn); + /** + * By deleting the copy constructor, we prevent accidentally using it when + * one intends to create a cache on top of a base cache. + */ + CCoinsViewCache(const CCoinsViewCache &) = delete; + // Standard CCoinsView methods bool GetCoin(const COutPoint &outpoint, Coin &coin) const override; bool HaveCoin(const COutPoint &outpoint) const override; @@ -289,12 +295,6 @@ private: CCoinsMap::iterator FetchCoin(const COutPoint &outpoint) const; - - /** - * By making the copy constructor private, we prevent accidentally using it - * when one intends to create a cache on top of a base cache. - */ - CCoinsViewCache(const CCoinsViewCache &); }; //! Utility function to add all of a transaction's outputs to a cache. diff --git a/src/net.h b/src/net.h --- a/src/net.h +++ b/src/net.h @@ -761,12 +761,11 @@ uint64_t nLocalHostNonceIn, const CAddress &addrBindIn, const std::string &addrNameIn = "", bool fInboundIn = false); ~CNode(); + CNode(const CNode &) = delete; + CNode &operator=(const CNode &) = delete; private: - CNode(const CNode &); - void operator=(const CNode &); const NodeId id; - const uint64_t nLocalHostNonce; // Services offered to this peer const ServiceFlags nLocalServices; diff --git a/src/streams.h b/src/streams.h --- a/src/streams.h +++ b/src/streams.h @@ -572,10 +572,6 @@ */ class CAutoFile { private: - // Disallow copies - CAutoFile(const CAutoFile &); - CAutoFile &operator=(const CAutoFile &); - const int nType; const int nVersion; @@ -589,6 +585,10 @@ ~CAutoFile() { fclose(); } + // Disallow copies + CAutoFile(const CAutoFile &) = delete; + CAutoFile &operator=(const CAutoFile &) = delete; + void fclose() { if (file) { ::fclose(file); @@ -686,10 +686,6 @@ */ class CBufferedFile { private: - // Disallow copies - CBufferedFile(const CBufferedFile &); - CBufferedFile &operator=(const CBufferedFile &); - const int nType; const int nVersion; @@ -735,6 +731,10 @@ ~CBufferedFile() { fclose(); } + // Disallow copies + CBufferedFile(const CBufferedFile &) = delete; + CBufferedFile &operator=(const CBufferedFile &) = delete; + int GetVersion() const { return nVersion; } int GetType() const { return nType; } diff --git a/src/support/lockedpool.h b/src/support/lockedpool.h --- a/src/support/lockedpool.h +++ b/src/support/lockedpool.h @@ -51,6 +51,9 @@ Arena(void *base, size_t size, size_t alignment); virtual ~Arena(); + Arena(const Arena &other) = delete; // non construction-copyable + Arena &operator=(const Arena &) = delete; // non copyable + /** Memory statistics. */ struct Stats { size_t used; @@ -89,11 +92,6 @@ bool addressInArena(void *ptr) const { return ptr >= base && ptr < end; } private: - // non construction-copyable - Arena(const Arena &other) = delete; - // non copyable - Arena &operator=(const Arena &) = delete; - /** * Map of chunk address to chunk information. This class makes use of the * sorted order to merge previous and next chunks during deallocation. @@ -165,6 +163,9 @@ LockingFailed_Callback lf_cb_in = nullptr); ~LockedPool(); + LockedPool(const LockedPool &other) = delete; // non construction-copyable + LockedPool &operator=(const LockedPool &) = delete; // non copyable + /** * Allocate size bytes from this arena. * Returns pointer on success, or 0 if memory is full or the application @@ -183,11 +184,6 @@ Stats stats() const; private: - // non construction-copyable - LockedPool(const LockedPool &other) = delete; - // non copyable - LockedPool &operator=(const LockedPool &) = delete; - std::unique_ptr allocator; /** Create an arena from locked pages */ diff --git a/src/wallet/db.h b/src/wallet/db.h --- a/src/wallet/db.h +++ b/src/wallet/db.h @@ -158,6 +158,9 @@ bool fFlushOnCloseIn = true); ~CDB() { Close(); } + CDB(const CDB &) = delete; + CDB &operator=(const CDB &) = delete; + void Flush(); void Close(); static bool Recover(const std::string &filename, void *callbackDataIn, @@ -180,10 +183,6 @@ std::string &errorStr, CDBEnv::recoverFunc_type recoverFunc); -private: - CDB(const CDB &); - void operator=(const CDB &); - public: template bool Read(const K &key, T &value) { if (!pdb) { diff --git a/src/wallet/walletdb.h b/src/wallet/walletdb.h --- a/src/wallet/walletdb.h +++ b/src/wallet/walletdb.h @@ -162,6 +162,8 @@ explicit CWalletDB(CWalletDBWrapper &dbw, const char *pszMode = "r+", bool _fFlushOnClose = true) : batch(dbw, pszMode, _fFlushOnClose), m_dbw(dbw) {} + CWalletDB(const CWalletDB &) = delete; + CWalletDB &operator=(const CWalletDB &) = delete; bool WriteName(const CTxDestination &address, const std::string &strName); bool EraseName(const CTxDestination &address); @@ -265,9 +267,6 @@ private: CDB batch; CWalletDBWrapper &m_dbw; - - CWalletDB(const CWalletDB &); - void operator=(const CWalletDB &); }; //! Compacts BDB state so that wallet.dat is self-contained (if there are