Luna::UniquePtr
A smart pointer that wraps one dynamically created object, and deletes the object when the pointer is destructed.
template <typename _Ty, typename _Deleter>
class Luna::UniquePtr
Parameters
-
_Ty
The type of the object to wrap.
-
_Deleter
The object deletion function to use.
Member functions
-
Constructs one null smart pointer.
-
constexpr UniquePtr(nullptr_t)
Constructs one null smart pointer with
nullptr_t
. -
Constructs one smart pointer by wrapping pointer
p
. -
UniquePtr(pointer p, const deleter_type &d)
Constructs one smart pointer by wrapping pointer
p
with custom object deletion function. -
UniquePtr(pointer p, deleter_type &&d)
Constructs one smart pointer by wrapping pointer
p
with custom object deletion function. -
Gets the underlying native pointer.
-
Get the object deletion function.
-
const deleter_type & get_deleter() const
Get the object deletion function.
-
Checks whether this smart pointer is not null.
-
add_lvalue_reference< _Ty >::type operator*() const
Dereferences the native pointer.
-
Accesses members of the instance pointed by the pointer.
-
Sets the native pointer to null, and gets the original pointer.
-
void reset(pointer ptr=pointer())
Sets the native pointer of this smart pointer. If this smart pointer is not null, the original instance pointed by this smart pointer will be deleted.
-
Swaps native pointers of this smart pointer with the specified smart pointer.
-
Constructs one smart pointer by moving native pointer from another smart pointer.
-
UniquePtr & operator=(UniquePtr &&rhs)
Assigns one smart pointer by moving native pointer from another smart pointer. If this smart pointer is not null, the original instance pointed by this smart pointer will be deleted.
-
UniquePtr & operator=(nullptr_t)
Sets one smart pointer to null. If this smart pointer is not null, the original instance pointed by this smart pointer will be deleted.
-
bool operator==(const UniquePtr &rhs) const
Compares two smart pointers for equality. Two smart pointers are equal if their native pointers are equal or both null.
-
bool operator!=(const UniquePtr &rhs) const
Compares two smart pointers for non-equality.