docs
Loading...
Searching...
No Matches
RefPtr< T >

#include <Ultralight/RefPtr.h>

Overview

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
RefPtr & operator= (const RefPtr &)
RefPtr & operator= (T *)
RefPtr & operator= (std::nullptr_t)
template<typename U>
RefPtr & operator= (const RefPtr< U > &)
RefPtr & operator= (RefPtr &&)
template<typename U>
RefPtr & operator= (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 &reference)
 Helper for wrapping new objects with the RefPtr smart pointer.

Member Typedef Documentation

◆ UnspecifiedBoolType

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

Member Enumeration Documentation

◆ AdoptTag

template<typename T>
enum AdoptTag
protected
Enumerator
Adopt 

Constructor & Destructor Documentation

◆ RefPtr() [1/8]

template<typename T>
RefPtr ( )
inlineconstexpr

Construct a NULL ref-pointer.

◆ RefPtr() [2/8]

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

Construct a NULL ref-pointer.

◆ RefPtr() [3/8]

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

Construct from a pointer.

(Will increment ref-count by one)

◆ RefPtr() [4/8]

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

Copy constructor.

◆ RefPtr() [5/8]

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

Copy constructor with internal type conversion.

◆ RefPtr() [6/8]

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

Move constructor.

◆ RefPtr() [7/8]

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

Move constructor.

◆ ~RefPtr()

template<typename T>
~RefPtr ( )
inline

Destroy RefPtr (wll decrement ref-count by one).

◆ RefPtr() [8/8]

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

Member Function Documentation

◆ get()

template<typename T>
T * get ( ) const
inline

Get a pointer to wrapped object.

◆ LeakRef()

template<typename T>
T * LeakRef ( )
inline

◆ operator UnspecifiedBoolType()

template<typename T>
operator UnspecifiedBoolType ( ) const
inline

◆ operator!()

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

◆ operator*()

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

◆ operator->()

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

◆ operator=() [1/8]

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

◆ operator=() [2/8]

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

◆ operator=() [3/8]

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

◆ operator=() [4/8]

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

◆ operator=() [5/8]

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

◆ operator=() [6/8]

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

◆ operator=() [7/8]

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

◆ operator=() [8/8]

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

◆ reset() [1/2]

template<typename T>
void reset ( )

Releases the ownership of the managed object, if any.

◆ reset() [2/2]

template<typename T>
void reset ( T * obj)

Replaces the managed object with another.

◆ swap()

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

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

Reference counts, if any, are not adjusted.

◆ 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: