|
Discontinuous Galerkin Library
#include "dg/algorithm.h"
|
Manager class that invokes the clone() method on the managed ptr when copied.
More...
Public Member Functions | |
| ClonePtr () | |
| init an empty ClonePtr | |
| ClonePtr (std::nullptr_t) | |
| init an empty ClonePtr | |
| ClonePtr (Cloneable *ptr) | |
| take ownership of the pointer | |
| ClonePtr (const Cloneable &src) | |
| clone the given value and manage | |
| ClonePtr (const ClonePtr &src) | |
deep copy the given handle using the clone() method of Cloneable | |
| ClonePtr & | operator= (const ClonePtr &src) |
deep copy the given handle using the clone() method of Cloneable | |
| ClonePtr (ClonePtr &&src) noexcept | |
| Steal resources (move construct) | |
| ClonePtr & | operator= (ClonePtr &&src) noexcept |
| Steal resources (move assignment) | |
| void | reset (Cloneable *ptr) |
| Replace the managed object. | |
| Cloneable * | release () noexcept |
Releases ownership of managed object, get() returns nullptr after call. | |
| void | reset (const Cloneable &src) |
| Clone the given object and replace the currently held one. | |
| Cloneable * | get () |
| Get a pointer to the object on the heap. | |
| const Cloneable * | get () const |
| Get a constant pointer to the object on the heap. | |
| Cloneable & | operator* () |
Dereference pointer to owned object, i.e. *get() | |
| const Cloneable & | operator* () const |
Dereference pointer to owned object, i.e. *get() | |
| Cloneable * | operator-> () |
Dereference pointer to owned object, i.e. get() | |
| const Cloneable * | operator-> () const |
Dereference pointer to owned object, i.e. get() | |
| operator bool () const | |
true if *this owns an object, false else | |
Friends | |
| void | swap (ClonePtr &first, ClonePtr &second) |
| swap the managed pointers | |
Manager class that invokes the clone() method on the managed ptr when copied.
When copied invokes a deep copy using the clone() method. This class is most useful when a class needs to hold a polymorphic, Cloneable oject as a variable.
| Cloneable | a type that may be uncopyable/unassignable but provides the clone() method with signature
|
|
inline |
init an empty ClonePtr
|
inline |
init an empty ClonePtr
|
inline |
take ownership of the pointer
| ptr | a pointer to object to manage |
|
inline |
clone the given value and manage
src is cloned, src is allowed to go out of scope after ClonePtr was initialized. | src | an object to clone |
|
inline |
deep copy the given handle using the clone() method of Cloneable
| src | an oject to copy, clones the contained object if not empty |
|
inlinenoexcept |
Steal resources (move construct)
| src | an object to steal pointer from |
|
inline |
Get a pointer to the object on the heap.
nullptr if no object owned
|
inline |
Get a constant pointer to the object on the heap.
nullptr if no object owned
|
inlineexplicit |
true if *this owns an object, false else
|
inline |
Dereference pointer to owned object, i.e. *get()
|
inline |
Dereference pointer to owned object, i.e. *get()
|
inline |
Dereference pointer to owned object, i.e. get()
|
inline |
Dereference pointer to owned object, i.e. get()
|
inlinenoexcept |
Steal resources (move assignment)
| src | an object to steal pointer from |
|
inline |
deep copy the given handle using the clone() method of Cloneable
| src | an oject to copy and swap |
|
inlinenoexcept |
Releases ownership of managed object, get() returns nullptr after call.
|
inline |
Replace the managed object.
Take the ownership of the given pointer and delete the currently held one if non-empty
| ptr | a pointer to a new object to manage |
|
inline |
Clone the given object and replace the currently held one.
| src | a Cloneable object |
|
friend |
swap the managed pointers
This follows the discussion in https://stackoverflow.com/questions/5695548/public-friend-swap-member-function
| first | first instance |
| second | second instance |