kodi
Public Member Functions | List of all members
XBMCAddon::AddonClass::Ref< T > Class Template Reference

This class is a smart pointer for a Referenced class. More...

#include <AddonClass.h>

Public Member Functions

 Ref (const T *_ac)
 
 Ref (Ref< T > const &oref)
 
template<class O >
 Ref (Ref< O > const &oref)
 
Ref< T > & operator= (Ref< T > const &oref)
 operator= should work with either another smart pointer or a pointer since it will be able to convert a pointer to a smart pointer using one of the above constructors. More...
 
T * operator-> () const
 
 operator T* () const
 This operator doubles as the value in a boolean expression.
 
T * get () const
 
T & getRef () const
 
bool isNull () const
 
bool isNotNull () const
 
bool isSet () const
 
bool operator! () const
 
bool operator== (const AddonClass::Ref< T > &oref) const
 
bool operator< (const AddonClass::Ref< T > &oref) const
 
template<class O >
void reset (Ref< O > const &oref)
 
template<class O >
void reset (O *oref)
 
void reset ()
 

Detailed Description

template<class T>
class XBMCAddon::AddonClass::Ref< T >

This class is a smart pointer for a Referenced class.

Member Function Documentation

◆ operator=()

template<class T>
Ref<T>& XBMCAddon::AddonClass::Ref< T >::operator= ( Ref< T > const &  oref)
inline

operator= should work with either another smart pointer or a pointer since it will be able to convert a pointer to a smart pointer using one of the above constructors.

Note: There is a trick here. The temporary variable is necessary because otherwise the following code will fail:

Ref<T> ptr = new T; ptr = ptr;

What happens without the tmp is the dereference is called first so the object ends up deleted and then the reference happens on a deleted object. The order is reversed in the following.

Note: Operator= is ambiguous if you define both an operator=(Ref<T>&) and an operator=(T*). I'm opting for the route the boost took here figuring it has more history behind it.


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