Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
|
Specialisation of copy on write pointer for classes based with copy on write pointer base. More...
#include <memory.hpp>
Public Member Functions | |
cow_shared_ptr (const cow_shared_ptr &other)=default | |
Copy constructor to create new instance of shared pointer reffering the same data. More... | |
cow_shared_ptr (cow_shared_ptr &&other) noexcept=default | |
Move constructor to create new instance of shared pointer reffering the same data. More... | |
~cow_shared_ptr () noexcept=default | |
The destructor of the shared pointer. More... | |
cow_shared_ptr & | operator= (const cow_shared_ptr &other)=default |
Copy assignment operator to change reffered instace to source one. More... | |
cow_shared_ptr & | operator= (cow_shared_ptr &&other) noexcept=default |
Move assignment operator to change reffered instace to source one. More... | |
void | reset () noexcept |
Sets the shared pointer to nullptr. More... | |
template<class Y > | |
void | reset (Y *ptr) |
Sets the shared pointer to value. More... | |
T * | operator-> () |
Operator arrow to chain dereferece to inner managed pointer. More... | |
T const * | operator-> () const |
Operator arrow to chain dereferece to inner managed pointer. More... | |
T & | operator* () |
Operator dereference to access the inner managed pointer. More... | |
T const & | operator* () const |
Operator dereference to access the inner managed pointer. More... | |
T * | get () |
T const * | get () const |
bool | unique () const |
Tests whether the managed pointer is referenced from one location only (or the class stores null pointer). More... | |
unsigned | use_count () const |
Getter of the number how many times the managed pointer is referenced. More... | |
operator bool () const | |
Friends | |
void | swap (cow_shared_ptr &first, cow_shared_ptr &second) |
Specialisation of swap method to copy on write shared pointers. More... | |
Specialisation of copy on write pointer for classes based with copy on write pointer base.
The class is essentially mimicking the behavior of shared_ptr. Additionaly the use of dereference (either through operator* or operator->) in non-constant context causes the managed pointer to ensure the referenced object is referenced from this class only.
The class also uniques the referenced instances when they are equal.
T | the type of managed objects |
|
default |
Copy constructor to create new instance of shared pointer reffering the same data.
other | the source instance |
|
defaultnoexcept |
Move constructor to create new instance of shared pointer reffering the same data.
other | the source instance |
|
defaultnoexcept |
The destructor of the shared pointer.
|
inline |
Getter of the raw managed pointer.
|
inline |
Getter of the raw managed pointer.
|
inlineexplicit |
Tests the instance whether the managed pointer is valid
|
inline |
Operator dereference to access the inner managed pointer.
|
inline |
Operator dereference to access the inner managed pointer.
|
inline |
Operator arrow to chain dereferece to inner managed pointer.
|
inline |
Operator arrow to chain dereferece to inner managed pointer.
|
default |
Copy assignment operator to change reffered instace to source one.
other | the source instance |
|
defaultnoexcept |
Move assignment operator to change reffered instace to source one.
other | the source instance |
|
inlinenoexcept |
Sets the shared pointer to nullptr.
Sets the shared pointer to value.
ptr | the value to store |
|
inline |
Tests whether the managed pointer is referenced from one location only (or the class stores null pointer).
|
inline |
Getter of the number how many times the managed pointer is referenced.
|
friend |
Specialisation of swap method to copy on write shared pointers.
first | the first instance |
second | the second instance |