![]() |
MySQL 9.2.0
Source Code Documentation
|
Smart pointer to hold a unique pointer to a heap allocated memory of type T
, constructed using a specific allocator.
More...
#include <unique_ptr.h>
Public Types | |
using | type = typename std::remove_extent< T >::type |
using | pointer = type * |
using | reference = type & |
Public Member Functions | |
template<typename D = T, typename B = A, std::enable_if_t< std::is_same< B, std::nullptr_t >::value > * = nullptr> | |
Unique_ptr () | |
Default class constructor, only to be used with no specific allocator. More... | |
template<typename D = T, typename B = A, std::enable_if_t<!std::is_same< B, std::nullptr_t >::value > * = nullptr> | |
Unique_ptr (A &alloc) | |
Class constructor, to be used with specific allocators, passing the allocator object to be used. More... | |
template<typename D = T, typename B = A, std::enable_if_t<!std::is_same< B, std::nullptr_t >::value &&std::is_array< D >::value > * = nullptr> | |
Unique_ptr (A &alloc, size_t size) | |
Class constructor, to be used with specific allocators and when T is an array type, passing the allocator object to be used and the size of the array. More... | |
template<typename D = T, typename B = A, std::enable_if_t< std::is_same< B, std::nullptr_t >::value &&std::is_array< D >::value > * = nullptr> | |
Unique_ptr (size_t size) | |
Class constructor, to be used with no specific allocators and when T is an array type, passing the allocator object to be used and the size of the array. More... | |
template<typename... Args, typename D = T, typename B = A, std::enable_if_t<!std::is_same< B, std::nullptr_t >::value &&!std::is_array< D >::value > * = nullptr> | |
Unique_ptr (A &alloc, Args &&...args) | |
Class constructor, to be used with specific allocators and when T is not an array type, passing the allocator object to be used and the parameters to be used with T object constructor. More... | |
template<typename... Args, typename D = T, typename B = A, std::enable_if_t< std::is_same< B, std::nullptr_t >::value &&!std::is_array< D >::value > * = nullptr> | |
Unique_ptr (Args &&...args) | |
Class constructor, to be used with no specific allocators and when T is not an array type, passing the parameters to be used with T object constructor. More... | |
Unique_ptr (Unique_ptr< T, A > const &rhs)=delete | |
Unique_ptr (Unique_ptr< T, A > &&rhs) | |
Move constructor. More... | |
virtual | ~Unique_ptr () |
Destructor for the class. More... | |
Unique_ptr< T, A > & | operator= (Unique_ptr< T, A > const &rhs)=delete |
Unique_ptr< T, A > & | operator= (Unique_ptr< T, A > &&rhs) |
Move operator. More... | |
template<typename D = T, std::enable_if_t<!std::is_array< D >::value > * = nullptr> | |
pointer | operator-> () const |
Arrow operator to access the underlying object of type T . More... | |
reference | operator* () const |
Star operator to access the underlying object of type T . More... | |
template<typename D = T, std::enable_if_t< std::is_array< D >::value > * = nullptr> | |
reference | operator[] (size_t index) const |
Subscript operator, to access an array element when T is of array type. More... | |
operator bool () const | |
Casting operator to bool. More... | |
template<typename B = A, std::enable_if_t< std::is_same< B, std::nullptr_t >::value > * = nullptr> | |
pointer | release () |
Releases the ownership of the underlying allocated memory and returns a pointer to the beginning of that memory. More... | |
template<typename B = A, std::enable_if_t<!std::is_same< B, std::nullptr_t >::value > * = nullptr> | |
pointer | release () |
Releases the ownership of the underlying allocated memory and returns a pointer to the beginning of that memory. More... | |
pointer | get () const |
Returns a pointer to the underlying allocated memory. More... | |
size_t | size () const |
The size of the memory allocated, in bytes. More... | |
template<typename D = T, typename B = A, std::enable_if_t< std::is_array< D >::value &&std::is_same< B, std::nullptr_t >::value > * = nullptr> | |
Unique_ptr< T, A > & | reserve (size_t new_size) |
Will resize the allocated memory to new_size . More... | |
template<typename D = T, typename B = A, std::enable_if_t< std::is_array< D >::value &&!std::is_same< B, std::nullptr_t >::value > * = nullptr> | |
Unique_ptr< T, A > & | reserve (size_t new_size) |
Will resize the allocated memory to new_size . More... | |
A & | allocator () const |
Returns the used allocator instance, if any. More... | |
template<typename D , std::enable_if_t<!std::is_array< D >::value > * > | |
memory::Unique_ptr< T, A >::pointer | operator-> () const |
template<typename D , std::enable_if_t< std::is_array< D >::value > * > | |
memory::Unique_ptr< T, A >::reference | operator[] (size_t index) const |
template<typename B , std::enable_if_t< std::is_same< B, std::nullptr_t >::value > * > | |
memory::Unique_ptr< T, A >::pointer | release () |
template<typename D , typename B , std::enable_if_t< std::is_array< D >::value &&std::is_same< B, std::nullptr_t >::value > * > | |
memory::Unique_ptr< T, A > & | reserve (size_t new_size) |
template<typename D , std::enable_if_t< std::is_array< D >::value > * > | |
memory::Unique_ptr< T, A >::pointer | clone () const |
Private Member Functions | |
void | reset () |
Clears the underlying pointer and size. More... | |
template<typename D = T, typename B = A, std::enable_if_t< std::is_same< B, std::nullptr_t >::value &&std::is_array< D >::value > * = nullptr> | |
void | destroy () |
Deallocates the underlying allocated memory. More... | |
template<typename D = T, typename B = A, std::enable_if_t< std::is_same< B, std::nullptr_t >::value &&!std::is_array< D >::value > * = nullptr> | |
void | destroy () |
Deallocates the underlying allocated memory. More... | |
template<typename D = T, typename B = A, std::enable_if_t<!std::is_same< B, std::nullptr_t >::value &&std::is_array< D >::value > * = nullptr> | |
void | destroy () |
Deallocates the underlying allocated memory. More... | |
template<typename D = T, typename B = A, std::enable_if_t<!std::is_same< B, std::nullptr_t >::value &&!std::is_array< D >::value > * = nullptr> | |
void | destroy () |
Deallocates the underlying allocated memory. More... | |
template<typename D = T, std::enable_if_t< std::is_array< D >::value > * = nullptr> | |
pointer | clone () const |
Clones the underlying memory and returns a pointer to the clone memory. More... | |
template<typename D = T, std::enable_if_t<!std::is_array< D >::value > * = nullptr> | |
pointer | clone () const |
Clones the underlying memory and returns a pointer to the clone memory. More... | |
Private Attributes | |
pointer | m_underlying {nullptr} |
The pointer to the underlying allocated memory More... | |
memory::Ref_ptr< A > | m_allocator |
The allocator to be used to allocate memory. More... | |
size_t | m_size {0} |
The size of the allocated memory. More... | |
Smart pointer to hold a unique pointer to a heap allocated memory of type T
, constructed using a specific allocator.
Template parameters are as follows:
T
is the type of the pointer to allocate. It may be an array type.A
the allocator to use. If none is passed, std::nullptr_t
is passed and regular new
and delete
are used to construct the memory. using memory::Unique_ptr< T, A >::pointer = type * |
using memory::Unique_ptr< T, A >::reference = type & |
using memory::Unique_ptr< T, A >::type = typename std::remove_extent<T>::type |
memory::Unique_ptr< T, A >::Unique_ptr |
Default class constructor, only to be used with no specific allocator.
memory::Unique_ptr< T, A >::Unique_ptr | ( | A & | alloc | ) |
Class constructor, to be used with specific allocators, passing the allocator object to be used.
alloc | The allocator instance to be used. |
memory::Unique_ptr< T, A >::Unique_ptr | ( | A & | alloc, |
size_t | size | ||
) |
Class constructor, to be used with specific allocators and when T
is an array type, passing the allocator object to be used and the size of the array.
alloc | The allocator instance to be used. |
size | The size of the array to allocate. |
memory::Unique_ptr< T, A >::Unique_ptr | ( | size_t | size | ) |
Class constructor, to be used with no specific allocators and when T
is an array type, passing the allocator object to be used and the size of the array.
size | The size of the array to allocate. |
memory::Unique_ptr< T, A >::Unique_ptr | ( | A & | alloc, |
Args &&... | args | ||
) |
Class constructor, to be used with specific allocators and when T
is not an array type, passing the allocator object to be used and the parameters to be used with T
object constructor.
alloc | The allocator instance to be used. |
args | The parameters to be used with T object constructor. |
memory::Unique_ptr< T, A >::Unique_ptr | ( | Args &&... | args | ) |
Class constructor, to be used with no specific allocators and when T
is not an array type, passing the parameters to be used with T
object constructor.
args | The parameters to be used with T object constructor. |
|
delete |
memory::Unique_ptr< T, A >::Unique_ptr | ( | memory::Unique_ptr< T, A > && | rhs | ) |
Move constructor.
rhs | The object to move data from. |
|
virtual |
Destructor for the class.
A & memory::Unique_ptr< T, A >::allocator |
Returns the used allocator instance, if any.
|
private |
Clones the underlying memory and returns a pointer to the clone memory.
|
private |
Clones the underlying memory and returns a pointer to the clone memory.
memory::Unique_ptr< T, A >::pointer memory::Unique_ptr< T, A >::clone |
|
private |
Deallocates the underlying allocated memory.
|
private |
Deallocates the underlying allocated memory.
|
private |
Deallocates the underlying allocated memory.
|
private |
Deallocates the underlying allocated memory.
memory::Unique_ptr< T, A >::pointer memory::Unique_ptr< T, A >::get |
Returns a pointer to the underlying allocated memory.
memory::Unique_ptr< T, A >::operator bool |
Casting operator to bool.
true
if the underlying pointer is instantiated, false
otherwise. memory::Unique_ptr< T, A >::reference memory::Unique_ptr< T, A >::operator* |
Star operator to access the underlying object of type T
.
T
. pointer memory::Unique_ptr< T, A >::operator-> | ( | ) | const |
Arrow operator to access the underlying object of type T
.
T
. memory::Unique_ptr< T, A >::pointer memory::Unique_ptr< T, A >::operator-> | ( | ) | const |
memory::Unique_ptr< T, A > & memory::Unique_ptr< T, A >::operator= | ( | memory::Unique_ptr< T, A > && | rhs | ) |
Move operator.
rhs | The object to move data from. |
|
delete |
reference memory::Unique_ptr< T, A >::operator[] | ( | size_t | index | ) | const |
Subscript operator, to access an array element when T
is of array type.
index | The index of the element to retrieve the value for. |
memory::Unique_ptr< T, A >::reference memory::Unique_ptr< T, A >::operator[] | ( | size_t | index | ) | const |
pointer memory::Unique_ptr< T, A >::release | ( | ) |
Releases the ownership of the underlying allocated memory and returns a pointer to the beginning of that memory.
This smart pointer will no longer manage the underlying memory.
pointer memory::Unique_ptr< T, A >::release | ( | ) |
Releases the ownership of the underlying allocated memory and returns a pointer to the beginning of that memory.
This smart pointer will no longer manage the underlying memory.
memory::Unique_ptr< T, A >::pointer memory::Unique_ptr< T, A >::release |
Unique_ptr< T, A > & memory::Unique_ptr< T, A >::reserve | ( | size_t | new_size | ) |
Will resize the allocated memory to new_size
.
If the configure allocator supports this operation, the allocator is used. If not, a new memory chunk is allocated and the memory is copied.
new_size | The new desired size for the memory. |
this
object, for chaining purposed. Unique_ptr< T, A > & memory::Unique_ptr< T, A >::reserve | ( | size_t | new_size | ) |
Will resize the allocated memory to new_size
.
If the configure allocator supports this operation, the allocator is used. If not, a new memory chunk is allocated and the memory is copied.
new_size | The new desired size for the memory. |
this
object, for chaining purposed. memory::Unique_ptr< T, A > & memory::Unique_ptr< T, A >::reserve | ( | size_t | new_size | ) |
|
private |
Clears the underlying pointer and size.
size_t memory::Unique_ptr< T, A >::size |
The size of the memory allocated, in bytes.
|
private |
The allocator to be used to allocate memory.
|
private |
The size of the allocated memory.
|
private |
The pointer to the underlying allocated memory