Ultralight C++ API 1.4.0
|
#include <Ultralight/RefPtr.h>
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. | |
typedef T*RefPtr::* UnspecifiedBoolType |
|
protected |
|
inlineconstexpr |
Construct a NULL ref-pointer.
|
inline |
Construct a NULL ref-pointer.
|
inline |
Construct from a pointer.
(Will increment ref-count by one)
Copy constructor with internal type conversion.
|
inline |
Get a pointer to wrapped object.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
RefPtr< T > & operator= | ( | std::nullptr_t | ) |
RefPtr< T > & operator= | ( | T * | object | ) |
void reset | ( | ) |
Releases the ownership of the managed object, if any.
void reset | ( | T * | obj | ) |
Replaces the managed object with another.
void swap | ( | RefPtr< T > & | ptr | ) |
Exchanges the stored pointer values and the ownerships of *this and ptr.
Reference counts, if any, are not adjusted.
|
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());