A smart pointer that clones
the object it holds when it is copied.
More...
#include <ClonedPtr.h>
Public Types | |
using | value_type = T |
The type of the managed object. More... | |
Public Member Functions | |
ClonedPtr (T *p=nullptr) | |
Explicit constructor to create new ClonedPtr object. More... | |
ClonedPtr (std::nullptr_t) | |
Special constructor to create new ClonedPtr object promoting a nullptr. More... | |
~ClonedPtr () | |
The destructor deletes the managed object. More... | |
ClonedPtr (const ClonedPtr &other) | |
Copy construct by cloning the managed object based on the cloning policy. More... | |
ClonedPtr (ClonedPtr &&other) noexcept | |
Move construct by taking ownership of the managed object by the ClonedPtr object being moved and setting its pointer to nullptr . More... | |
ClonedPtr & | operator= (const ClonedPtr &other) |
Copy assign by cloning the managed object based on the cloning policy. More... | |
ClonedPtr & | operator= (ClonedPtr &&other) noexcept |
Move construct by taking ownership of the managed object by the ClonedPtr object being moved and setting its pointer to nullptr . More... | |
void | reset (T *p=nullptr) |
Reset method deletes the object that it currently managed and manages the object given by a raw pointer. More... | |
T * | release () noexcept |
Release the ownership of the currently managed object by returning the pointer and setting the held pointer to nullptr. More... | |
operator bool () const noexcept | |
convert ClonedPtr to bool , false if there is a managed object is else converts to true . More... | |
const T & | operator* () const |
Dereference the smart pointer. More... | |
T & | operator* () |
Dereference the smart pointer. More... | |
const T * | operator-> () const |
Struct dereference to access members of the managed object. More... | |
T * | operator-> () |
Struct dereference to access members of the managed object. More... | |
const T * | get () const |
Get the pointer managed by ClonedPtr object. More... | |
T * | get () |
Get the pointer managed by ClonedPtr object. More... | |
bool | operator== (const ClonedPtr &other) const |
Equal to another ClonedPtr object. More... | |
bool | operator!= (const ClonedPtr &other) const |
Not equal to another ClonedPtr object. More... | |
bool | operator< (const ClonedPtr &other) const |
Less than another ClonedPtr object. More... | |
bool | operator> (const ClonedPtr &other) const |
Greater than another ClonedPtr object. More... | |
bool | operator<= (const ClonedPtr &other) const |
Less than or equal to another ClonedPtr object. More... | |
bool | operator>= (const ClonedPtr &other) const |
Greater than or equal to another ClonedPtr object. More... | |
void | swap (ClonedPtr &other) |
Swap the managed objects of the this ClonedPtr object and another. More... | |
Detailed Description
template<typename T, typename Cloner = DeepCopy<T>>
class helib::ClonedPtr< T, Cloner >
A smart pointer that clones
the object it holds when it is copied.
- Template Parameters
-
T The type of object managed by the pointer. Cloner A policy of how to clone the object pointed to, either deep
orshallow
. The default isdeep
.
Member Typedef Documentation
◆ value_type
using helib::ClonedPtr< T, Cloner >::value_type = T |
The type of the managed object.
Constructor & Destructor Documentation
◆ ClonedPtr() [1/4]
|
inlineexplicit |
◆ ClonedPtr() [2/4]
|
inline |
Special constructor to create new ClonedPtr
object promoting a nullptr.
◆ ~ClonedPtr()
|
inline |
The destructor deletes the managed object.
◆ ClonedPtr() [3/4]
|
inline |
Copy construct by cloning the managed object based on the cloning policy.
- Parameters
-
other The ClonedPtr
object to be cloned.
◆ ClonedPtr() [4/4]
|
inlinenoexcept |
Member Function Documentation
◆ get() [1/2]
|
inline |
Get the pointer managed by ClonedPtr
object.
- Returns
- The raw pointer to the managed object.
◆ get() [2/2]
|
inline |
Get the pointer managed by ClonedPtr
object.
- Returns
- The
const
raw pointer to the managed object.
◆ operator bool()
|
inlineexplicitnoexcept |
convert ClonedPtr
to bool
, false
if there is a managed object is else converts to true
.
◆ operator!=()
|
inline |
◆ operator*() [1/2]
|
inline |
Dereference the smart pointer.
- Returns
- Reference to managed object.
◆ operator*() [2/2]
|
inline |
Dereference the smart pointer.
- Returns
const
reference to manged object.
◆ operator->() [1/2]
|
inline |
Struct dereference to access members of the managed object.
- Returns
- The raw pointer to the managed object.
◆ operator->() [2/2]
|
inline |
Struct dereference to access members of the managed object.
- Returns
- The
const
raw pointer to the managed object.
◆ operator<()
|
inline |
◆ operator<=()
|
inline |
◆ operator=() [1/2]
|
inlinenoexcept |
◆ operator=() [2/2]
|
inline |
Copy assign by cloning the managed object based on the cloning policy.
- Parameters
-
other The ClonedPtr
object to be cloned.
- Returns
- Reference to
*this
.
◆ operator==()
|
inline |
◆ operator>()
|
inline |
◆ operator>=()
|
inline |
◆ release()
|
inlinenoexcept |
Release the ownership of the currently managed object by returning the pointer and setting the held pointer to nullptr.
- Returns
- the pointer currently held by the
ClonedPtr
object.
◆ reset()
|
inline |
Reset method deletes the object that it currently managed and manages the object given by a raw pointer.
- Parameters
-
p The raw pointer to replace the raw pointer currently managed by the ClonedPtr
object. The default isnullptr
.
◆ swap()
|
inline |