Anope IRC Services  Version 2.0
Public Member Functions | Protected Attributes
Reference< T > Class Template Reference

#include <base.h>

Inheritance diagram for Reference< T >:
Inheritance graph
[legend]
Collaboration diagram for Reference< T >:
Collaboration graph
[legend]

Public Member Functions

 Reference ()
 
 Reference (T *obj)
 
 Reference (const Reference< T > &other)
 
virtual ~Reference ()
 
Reference< T > & operator= (const Reference< T > &other)
 
virtual operator bool ()
 
 operator T * ()
 
T * operator-> ()
 
T * operator* ()
 
bool operator== (const Reference< T > &other)
 
- Public Member Functions inherited from ReferenceBase
 ReferenceBase ()
 
 ReferenceBase (const ReferenceBase &other)
 
virtual ~ReferenceBase ()
 
void Invalidate ()
 

Protected Attributes

T * ref
 
- Protected Attributes inherited from ReferenceBase
bool invalid
 

Detailed Description

template<typename T>
class Reference< T >

Used to hold pointers to objects that may be deleted. A Reference will no longer be valid once the object it refers is destructed.

Definition at line 49 of file base.h.

Constructor & Destructor Documentation

template<typename T>
Reference< T >::Reference ( )
inline

Definition at line 54 of file base.h.

template<typename T>
Reference< T >::Reference ( T *  obj)
inline

Definition at line 58 of file base.h.

template<typename T>
Reference< T >::Reference ( const Reference< T > &  other)
inline

Definition at line 64 of file base.h.

template<typename T>
virtual Reference< T >::~Reference ( )
inlinevirtual

Definition at line 70 of file base.h.

Member Function Documentation

template<typename T>
virtual Reference< T >::operator bool ( )
inlinevirtual
template<typename T>
Reference< T >::operator T * ( )
inline

Definition at line 103 of file base.h.

template<typename T>
T* Reference< T >::operator* ( )
inline

Definition at line 117 of file base.h.

template<typename T>
T* Reference< T >::operator-> ( )
inline

Definition at line 110 of file base.h.

template<typename T>
Reference<T>& Reference< T >::operator= ( const Reference< T > &  other)
inline

Definition at line 76 of file base.h.

template<typename T>
bool Reference< T >::operator== ( const Reference< T > &  other)
inline

Note that we can't have an operator< that returns this->ref < other.ref because this function is used to sort objects in containers (such as set or map), and if the references themselves can change if the object they refer to is invalidated or changed, then this screws with the order that the objects would be in the container without properly adjusting the container, resulting in weird stuff.

As such, we don't allow storing references in containers that require operator<, because they would not be able to compare what the references actually referred to.

Definition at line 136 of file base.h.

Field Documentation

template<typename T>
T* Reference< T >::ref
protected

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