clone_tools::clone_ptr<T>
Defined in header <clone/clone_ptr.hpp>
Like std::unique_ptr
but requires the managed type to support cloning and then uses that to support copy-construction and copy-assignment by cloning the managed object.
Doesn't currently support:
- deleter
- array version
Member types
pointer type |
std::remove_reference<Deleter>::type::pointer if that type exists, otherwise T*. Must satisfy NullablePointer. |
element_type |
T, the type of the object managed by this unique_ptr |
Member functions
(constructor) |
constructs a new clone_tools::clone_ptr (public member function) |
(destructor) |
destructs the managed object (public member function) |
operator= |
assigns the clone_tools::clone_ptr (public member function) |
Modifiers |
|
release |
returns a pointer to the managed object and releases the ownership (public member function) |
reset |
replaces the managed object (public member function) |
swap |
swaps the managed objects (public member function) |
Observers |
|
get |
returns a pointer to the managed object (public member function) |
operator bool |
checks if there is associated managed object (public member function) |
operator* operator-> |
dereferences pointer to the managed object (public member function) |
Non-member functions
Within namespace clone_tools
TODO: make clear what (if anything) is the point of each of these functions.
make_unique |
constructs a new std::unique_ptr (function template) |
(until C++14) |
make_clone |
constructs a new std::clone_ptr (function template) |
|
make_clone_of_uptr |
creates a clone_ptr from a std::unique_ptr (copy/move) (function template) |
|
make_const_clone_of_uptr |
creates a const clone_ptr from a std::unique_ptr (copy/move) (function template) |
|
clone_and_make_clone |
clones an object into a clone_ptr (function template) |
|
clone_and_make_const_clone |
clones an object into a const clone_ptr (function template) |
Type trait gubbins
Within namespace clone_tools
Observers |
||
is_clone_v<> |
whether the type is a clone gubbins thing (variable template) |
since C++14 |
is_clone_v<> |
whether the type is a clone gubbins thing (variable template) |
since C++14 |
Observers |
||
is_unique_ptr_v<> |
whether the type is a clone gubbins thing (variable template) |
since C++14 |
is_unique_ptr_after_decay_v<> |
whether the type is a clone gubbins thing (variable template) |
since C++14 |
Example
#include <clone/clone_ptr.hpp>
const auto ptr_a = make_clone<concrete_type_a, base_type>( "hello" );
const auto ptr_b{ ptr_a };