Ultralight C++ API 1.3.0
Loading...
Searching...
No Matches
ultralight::RefPtr< T > Class Template Reference

#include <Ultralight/RefPtr.h>

Details

template<typename T>
class ultralight::RefPtr< T >

A nullable smart pointer.

This smart pointer automatically manages the lifetime of a RefCounted object. The managed instance may be NULL.

Public Types

typedef T *RefPtr::* UnspecifiedBoolType
 

Public Member Functions

constexpr RefPtr ()
 Construct a NULL ref-pointer.
 
 RefPtr (std::nullptr_t)
 Construct a NULL ref-pointer.
 
 RefPtr (T *other)
 Construct from a pointer.
 
 RefPtr (const RefPtr &other)
 Copy constructor.
 
template<typename U >
 RefPtr (const RefPtr< U > &other)
 Copy constructor with internal type conversion.
 
 RefPtr (RefPtr &&other)
 Move constructor.
 
template<typename U >
 RefPtr (RefPtr< U > &&other)
 Move constructor.
 
 ~RefPtr ()
 Destroy RefPtr (wll decrement ref-count by one)
 
T * get () const
 Get a pointer to wrapped object.
 
T * LeakRef ()
 
T & operator* () const
 
T * operator-> () const
 
bool operator! () const
 
 operator UnspecifiedBoolType () const
 
RefPtroperator= (const RefPtr &)
 
RefPtroperator= (T *)
 
RefPtroperator= (std::nullptr_t)
 
template<typename U >
RefPtroperator= (const RefPtr< U > &)
 
RefPtroperator= (RefPtr &&)
 
template<typename U >
RefPtroperator= (RefPtr< U > &&)
 
void reset ()
 Releases the ownership of the managed object, if any.
 
void reset (T *obj)
 Replaces the managed object with another.
 
void swap (RefPtr &ptr)
 Exchanges the stored pointer values and the ownerships of *this and ptr.
 
template<typename U >
RefPtr< T > & operator= (const RefPtr< U > &other)
 
template<typename U >
RefPtr< T > & operator= (RefPtr< U > &&other)
 

Protected Types

enum  AdoptTag { Adopt }
 

Protected Member Functions

 RefPtr (T &object, AdoptTag)
 

Friends

bool operator== (const RefPtr &a, const RefPtr &b)
 
bool operator!= (const RefPtr &a, const RefPtr &b)
 
bool operator< (const RefPtr &a, const RefPtr &b)
 
RefPtr AdoptRef (T &)
 Helper for wrapping new objects with the RefPtr smart pointer.
 

Member Typedef Documentation

◆ UnspecifiedBoolType

template<typename T >
typedef T*RefPtr::* ultralight::RefPtr< T >::UnspecifiedBoolType

Member Enumeration Documentation

◆ AdoptTag

template<typename T >
enum ultralight::RefPtr::AdoptTag
protected
Enumerator
Adopt 

Constructor & Destructor Documentation

◆ RefPtr() [1/8]

template<typename T >
constexpr ultralight::RefPtr< T >::RefPtr ( )
inlineconstexpr

Construct a NULL ref-pointer.

◆ RefPtr() [2/8]

template<typename T >
ultralight::RefPtr< T >::RefPtr ( std::nullptr_t  )
inline

Construct a NULL ref-pointer.

◆ RefPtr() [3/8]

template<typename T >
ultralight::RefPtr< T >::RefPtr ( T *  other)
inline

Construct from a pointer.

(Will increment ref-count by one)

◆ RefPtr() [4/8]

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

Copy constructor.

◆ RefPtr() [5/8]

template<typename T >
template<typename U >
ultralight::RefPtr< T >::RefPtr ( const RefPtr< U > &  other)
inline

Copy constructor with internal type conversion.

◆ RefPtr() [6/8]

template<typename T >
ultralight::RefPtr< T >::RefPtr ( RefPtr< T > &&  other)
inline

Move constructor.

◆ RefPtr() [7/8]

template<typename T >
template<typename U >
ultralight::RefPtr< T >::RefPtr ( RefPtr< U > &&  other)
inline

Move constructor.

◆ ~RefPtr()

template<typename T >
ultralight::RefPtr< T >::~RefPtr ( )
inline

Destroy RefPtr (wll decrement ref-count by one)

◆ RefPtr() [8/8]

template<typename T >
ultralight::RefPtr< T >::RefPtr ( T &  object,
AdoptTag   
)
inlineprotected

Member Function Documentation

◆ get()

template<typename T >
T * ultralight::RefPtr< T >::get ( ) const
inline

Get a pointer to wrapped object.

◆ LeakRef()

template<typename T >
T * ultralight::RefPtr< T >::LeakRef ( )
inline

◆ operator UnspecifiedBoolType()

template<typename T >
ultralight::RefPtr< T >::operator UnspecifiedBoolType ( ) const
inline

◆ operator!()

template<typename T >
bool ultralight::RefPtr< T >::operator! ( ) const
inline

◆ operator*()

template<typename T >
T & ultralight::RefPtr< T >::operator* ( ) const
inline

◆ operator->()

template<typename T >
T * ultralight::RefPtr< T >::operator-> ( ) const
inline

◆ operator=() [1/8]

template<typename T >
RefPtr< T > & ultralight::RefPtr< T >::operator= ( const RefPtr< T > &  other)

◆ operator=() [2/8]

template<typename T >
template<typename U >
RefPtr & ultralight::RefPtr< T >::operator= ( const RefPtr< U > &  )

◆ operator=() [3/8]

template<typename T >
template<typename U >
RefPtr< T > & ultralight::RefPtr< T >::operator= ( const RefPtr< U > &  other)

◆ operator=() [4/8]

template<typename T >
RefPtr< T > & ultralight::RefPtr< T >::operator= ( RefPtr< T > &&  other)

◆ operator=() [5/8]

template<typename T >
template<typename U >
RefPtr & ultralight::RefPtr< T >::operator= ( RefPtr< U > &&  )

◆ operator=() [6/8]

template<typename T >
template<typename U >
RefPtr< T > & ultralight::RefPtr< T >::operator= ( RefPtr< U > &&  other)

◆ operator=() [7/8]

template<typename T >
RefPtr< T > & ultralight::RefPtr< T >::operator= ( std::nullptr_t  )

◆ operator=() [8/8]

template<typename T >
RefPtr< T > & ultralight::RefPtr< T >::operator= ( T *  object)

◆ reset() [1/2]

template<typename T >
void ultralight::RefPtr< T >::reset

Releases the ownership of the managed object, if any.

◆ reset() [2/2]

template<typename T >
void ultralight::RefPtr< T >::reset ( T *  obj)

Replaces the managed object with another.

◆ swap()

template<typename T >
void ultralight::RefPtr< T >::swap ( RefPtr< T > &  ptr)

Exchanges the stored pointer values and the ownerships of *this and ptr.

Reference counts, if any, are not adjusted.

Friends And Related Symbol Documentation

◆ AdoptRef

template<typename T >
RefPtr AdoptRef ( T &  reference)
friend

Helper for wrapping new objects with the RefPtr smart pointer.

All ref-counted object are created with an initial ref-count of '1'. The AdoptRef() helper returns a RefPtr<T> without calling AddRef(). This is used for creating new objects, like so:

RefPtr<Object> ref = AdoptRef(*new ObjectImpl());

◆ operator!=

template<typename T >
bool operator!= ( const RefPtr< T > &  a,
const RefPtr< T > &  b 
)
friend

◆ operator<

template<typename T >
bool operator< ( const RefPtr< T > &  a,
const RefPtr< T > &  b 
)
friend

◆ operator==

template<typename T >
bool operator== ( const RefPtr< T > &  a,
const RefPtr< T > &  b 
)
friend

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