mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 06:58:57 +01:00
Merge #21366: refactor: replace util::Ref with std::any (C++17)
916ab0195dremove unused class util::Ref and its unit test (Sebastian Falbesoner)8dbb87a393refactor: replace util::Ref by std::any (C++17) (Sebastian Falbesoner)95cccf8a4butil: introduce helper AnyPtr to access std::any instances (Sebastian Falbesoner) Pull request description: As described in `util/ref.h`: "_This implements a small subset of the functionality in C++17's std::any class, and **can be dropped when the project updates to C++17**_". For accessing the contained object of a `std::any` instance, a helper template function `AnyPtr` is introduced (thanks to ryanofsky). ACKs for top commit: hebasto: re-ACK916ab0195d, with command ryanofsky: Code review ACK916ab0195d. Changes since last review: rebase and replacing types with `auto`. I might have used `const auto*` and `auto*` instead of plain `auto` because I think the qualifiers are useful, but this is all good. Tree-SHA512: fe2c3e4f5726f8ad40c61128339bb24ad11d2c261f71f7b934b1efe3e3279df14046452b0d9b566917ef61d5c7e0fd96ccbf35ff810357e305710f5002c27d47
This commit is contained in:
@@ -38,7 +38,6 @@
|
||||
#include <uint256.h>
|
||||
#include <univalue.h>
|
||||
#include <util/check.h>
|
||||
#include <util/ref.h>
|
||||
#include <util/system.h>
|
||||
#include <util/translation.h>
|
||||
#include <validation.h>
|
||||
@@ -49,6 +48,7 @@
|
||||
#include <config/bitcoin-config.h>
|
||||
#endif
|
||||
|
||||
#include <any>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <utility>
|
||||
@@ -298,13 +298,13 @@ public:
|
||||
{
|
||||
m_context = context;
|
||||
if (context) {
|
||||
m_context_ref.Set(*context);
|
||||
m_context_ref = context;
|
||||
} else {
|
||||
m_context_ref.Clear();
|
||||
m_context_ref.reset();
|
||||
}
|
||||
}
|
||||
NodeContext* m_context{nullptr};
|
||||
util::Ref m_context_ref;
|
||||
std::any m_context_ref;
|
||||
};
|
||||
|
||||
bool FillBlock(const CBlockIndex* index, const FoundBlock& block, UniqueLock<RecursiveMutex>& lock, const CChain& active)
|
||||
|
||||
Reference in New Issue
Block a user