10 #ifndef ThePEG_AnyReference_H 11 #define ThePEG_AnyReference_H 13 #include "ThePEG/Config/ThePEG.h" 14 #include "Exception.h" 34 virtual const std::type_info&
type()
const = 0;
74 virtual const std::type_info&
type()
const {
111 : holder(other.holder ? other.holder->
clone() : 0) {}
118 delete holder; holder = 0;
127 const std::type_info&
type()
const {
return holder ? holder->
type() :
typeid(void); }
140 std::swap(holder,other.
holder);
return *
this;
164 if ( holder )
delete holder; holder = 0;
185 #endif // ThePEG_AnyReference_H ReferenceHolder(T &v)
Construct from given reference.
~AnyReference()
The destructor.
T & cast() const
Extract the held reference.
virtual ReferenceHolderBase * clone() const =0
Clone this reference holder.
bool empty() const
Return true, if no reference is held.
AnyReference & operator=(AnyReference other)
Assign from AnyReference.
const std::type_info & type() const
Return the type held.
ReferenceHolderBase * holder
The reference holder used.
static T & init()
Static member to initialize the reference.
This is the main namespace within which all identifiers in ThePEG are declared.
T & value
The reference held.
virtual ~ReferenceHolderBase()
The destructor.
virtual ReferenceHolderBase * clone() const
Clone this reference holder.
AnyReference & swap(AnyReference &other)
Swap the references held.
virtual const std::type_info & type() const =0
Return the type held.
AnyReference()
The default constructor.
AnyReference & operator=(T &v)
Assign from definite type.
AnyReference(T &v)
The standard constructor.
AnyReference is inspired by boost::any to hold a reference to an object of arbitrary type...
virtual const std::type_info & type() const
Return the type held.
void reset()
Reset to not keep track of any reference.
Exception is the base class for all exceptions to be used in ThePEG.
AnyReference(const AnyReference &other)
The copy constructor.
ReferenceHolder()
The default constructor.
Severe error, (the run is aborted immediately, before the exception is thrown).