Template Class ref¶
Defined in File object.h
Page Contents
Class Documentation¶
-
template<typename
T
>
classref
¶ Reference counting helper.
The ref template is a simple wrapper to store a pointer to an object. It takes care of increasing and decreasing the object’s reference count as needed. When the last reference goes out of scope, the associated object will be deallocated.
The advantage over C++ solutions such as
std::shared_ptr
is that the reference count is very compactly integrated into the base object itself.Public Functions
-
ref
()¶ Create a
nullptr
-valued reference.
-
ref
(T *ptr)¶ Construct a reference from a pointer.
-
~ref
()¶ Destroy this reference.
-
ref &
operator=
(ref &&r)¶ Move another reference into the current one.
-
ref &
operator=
(const ref &r)¶ Overwrite this reference with another reference.
-
ref &
operator=
(T *ptr)¶ Overwrite this reference with a pointer to another object.
-
bool
operator==
(const ref &r) const¶ Compare this reference with another reference.
-
bool
operator!=
(const ref &r) const¶ Compare this reference with another reference.
-
bool
operator==
(const T *ptr) const¶ Compare this reference with a pointer.
-
bool
operator!=
(const T *ptr) const¶ Compare this reference with a pointer.
-
T *
operator->
()¶ Access the object referenced by this reference.
-
const T *
operator->
() const¶ Access the object referenced by this reference.
-
T &
operator*
()¶ Return a C++ reference to the referenced object.
-
const T &
operator*
() const¶ Return a const C++ reference to the referenced object.
-
operator T *
()¶ Return a pointer to the referenced object.
-
T *
get
()¶ Return a const pointer to the referenced object.
-
const T *
get
() const¶ Return a pointer to the referenced object.
-
operator bool
() const¶ Check if the object is defined.
-