thepeg is hosted by Hepforge, IPPP Durham
ThePEG 2.3.0
ThePEG::AnyReference Class Reference

AnyReference is inspired by boost::any to hold a reference to an object of arbitrary type. More...

#include <AnyReference.h>

Classes

struct  ReferenceHolder
 
struct  ReferenceHolderBase
 

Public Member Functions

 AnyReference ()
 The default constructor.
 
template<class T >
 AnyReference (T &v)
 The standard constructor.
 
 AnyReference (const AnyReference &other)
 The copy constructor.
 
 ~AnyReference ()
 The destructor.
 
const std::type_info & type () const
 Return the type held.
 
bool empty () const
 Return true, if no reference is held.
 
AnyReferenceswap (AnyReference &other)
 Swap the references held.
 
template<class T >
AnyReferenceoperator= (T &v)
 Assign from definite type.
 
AnyReferenceoperator= (AnyReference other)
 Assign from AnyReference.
 
void reset ()
 Reset to not keep track of any reference.
 
template<class T >
T & cast () const
 Extract the held reference.
 

Private Attributes

ReferenceHolderBaseholder
 The reference holder used.
 

Detailed Description

AnyReference is inspired by boost::any to hold a reference to an object of arbitrary type.

Definition at line 22 of file AnyReference.h.

Constructor & Destructor Documentation

◆ AnyReference() [1/3]

ThePEG::AnyReference::AnyReference ( )
inline

The default constructor.

Definition at line 97 of file AnyReference.h.

Referenced by operator=().

◆ AnyReference() [2/3]

template<class T >
ThePEG::AnyReference::AnyReference ( T &  v)
inline

The standard constructor.

Definition at line 104 of file AnyReference.h.

◆ AnyReference() [3/3]

ThePEG::AnyReference::AnyReference ( const AnyReference other)
inline

The copy constructor.

Definition at line 110 of file AnyReference.h.

◆ ~AnyReference()

ThePEG::AnyReference::~AnyReference ( )
inline

The destructor.

Definition at line 116 of file AnyReference.h.

References holder.

Member Function Documentation

◆ cast()

template<class T >
T & ThePEG::AnyReference::cast ( ) const
inline

Extract the held reference.

Definition at line 171 of file AnyReference.h.

References ThePEG::Exception::abortnow, empty(), holder, ThePEG::AnyReference::ReferenceHolder< T >::init(), and type().

◆ empty()

bool ThePEG::AnyReference::empty ( ) const
inline

Return true, if no reference is held.

Definition at line 130 of file AnyReference.h.

References holder.

Referenced by cast().

◆ operator=() [1/2]

AnyReference & ThePEG::AnyReference::operator= ( AnyReference  other)
inline

Assign from AnyReference.

Definition at line 153 of file AnyReference.h.

References swap().

◆ operator=() [2/2]

template<class T >
AnyReference & ThePEG::AnyReference::operator= ( T &  v)
inline

Assign from definite type.

Definition at line 145 of file AnyReference.h.

References AnyReference().

◆ reset()

void ThePEG::AnyReference::reset ( )
inline

Reset to not keep track of any reference.

Definition at line 161 of file AnyReference.h.

References holder.

◆ swap()

AnyReference & ThePEG::AnyReference::swap ( AnyReference other)
inline

Swap the references held.

Definition at line 137 of file AnyReference.h.

References holder, and std::swap().

Referenced by operator=().

◆ type()

const std::type_info & ThePEG::AnyReference::type ( ) const
inline

Return the type held.

Definition at line 125 of file AnyReference.h.

References holder, and ThePEG::AnyReference::ReferenceHolderBase::type().

Referenced by cast().

Member Data Documentation

◆ holder

ReferenceHolderBase* ThePEG::AnyReference::holder
private

The reference holder used.

Definition at line 90 of file AnyReference.h.

Referenced by cast(), empty(), reset(), swap(), type(), and ~AnyReference().


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