Bitcoin Core  0.20.99
P2P Digital Currency
Public Member Functions | Private Attributes | List of all members
util::Ref Class Reference

Type-safe dynamic reference. More...

#include <ref.h>

Public Member Functions

 Ref ()=default
 
template<typename T >
 Ref (T &value)
 
template<typename T >
T & Get () const
 
template<typename T >
void Set (T &value)
 
template<typename T >
bool Has () const
 
void Clear ()
 

Private Attributes

void * m_value = nullptr
 
std::type_index m_type = std::type_index(typeid(void))
 

Detailed Description

Type-safe dynamic reference.

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 (https://github.com/bitcoin/bitcoin/issues/16684)

Definition at line 21 of file ref.h.

Constructor & Destructor Documentation

◆ Ref() [1/2]

util::Ref::Ref ( )
default

◆ Ref() [2/2]

template<typename T >
util::Ref::Ref ( T &  value)
inline

Definition at line 25 of file ref.h.

Here is the call graph for this function:

Member Function Documentation

◆ Clear()

void util::Ref::Clear ( )
inline

Definition at line 29 of file ref.h.

◆ Get()

template<typename T >
T& util::Ref::Get ( ) const
inline

Definition at line 26 of file ref.h.

Here is the caller graph for this function:

◆ Has()

template<typename T >
bool util::Ref::Has ( ) const
inline

Definition at line 28 of file ref.h.

Here is the caller graph for this function:

◆ Set()

template<typename T >
void util::Ref::Set ( T &  value)
inline

Definition at line 27 of file ref.h.

Here is the caller graph for this function:

Member Data Documentation

◆ m_type

std::type_index util::Ref::m_type = std::type_index(typeid(void))
private

Definition at line 33 of file ref.h.

◆ m_value

void* util::Ref::m_value = nullptr
private

Definition at line 32 of file ref.h.


The documentation for this class was generated from the following file: