Ultralight  1.0.0
A fast, lightweight, HTML UI engine for native apps.
ultralight::Ref< T > Class Template Reference

A non-nullable smart pointer. More...

#include <RefPtr.h>

Public Member Functions

 ~Ref ()
 Destroy Ref (wll decrement ref-count by one)
 
 Ref (T &object)
 Construct Ref from a reference. More...
 
 Ref (const Ref &other)
 Copy constructor.
 
template<typename U >
 Ref (Ref< U > &other)
 Copy constructor with internal type conversion.
 
template<typename U >
 Ref (const Ref< U > &other)
 Copy constructor with internal type conversion.
 
 Ref (Ref &&other)
 Move constructor.
 
template<typename U >
 Ref (Ref< U > &&other)
 Move constructor.
 
const T * ptr () const
 Get a pointer to wrapped object.
 
T * ptr ()
 Get a pointer to wrapped object.
 
const T & get () const
 Get a reference to wrapped object.
 
T & get ()
 Get a reference to wrapped object.
 

Friends

Ref AdoptRef (T &)
 Helper for wrapping new objects with the Ref smart pointer. More...
 

Detailed Description

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

A non-nullable smart pointer.

This smart pointer automatically manages the lifetime of a RefCounted object. Also guarantees that the managed instance is not NULL.

Definition at line 64 of file RefPtr.h.

Constructor & Destructor Documentation

◆ Ref()

template<typename T>
ultralight::Ref< T >::Ref ( T &  object)
inline

Construct Ref from a reference.

(Will increment ref-count by one)

Definition at line 97 of file RefPtr.h.

Friends And Related Function Documentation

◆ AdoptRef

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

Helper for wrapping new objects with the Ref smart pointer.

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

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

Definition at line 269 of file RefPtr.h.


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