mn::pointer::basic_unique_ptr< T, TAllocator, TDeleter > Class Template Reference

A simple unique_ptr, for a single object. More...

#include <mn_unique_ptr.hpp>

+ Inheritance diagram for mn::pointer::basic_unique_ptr< T, TAllocator, TDeleter >:
+ Collaboration diagram for mn::pointer::basic_unique_ptr< T, TAllocator, TDeleter >:

Public Types

using value_type = T
 
using pointer = T *
 
using const_pointer = const T *
 
using reference = T &
 
using const_reference = const T &
 
using deleter_type = TDeleter
 
using allotor_type = TAllocator
 
using self_type = basic_unique_ptr< value_type, allotor_type, deleter_type >
 
- Public Types inherited from mn::only_move_tag< void >
using this_type = only_move_tag
 

Public Member Functions

constexpr basic_unique_ptr () noexcept
 Constructor a basic_unique_ptr that owns nothing. More...
 
constexpr basic_unique_ptr (nullptr_t) noexcept
 Creates a unique_ptr that owns nothing. More...
 
 basic_unique_ptr (pointer pPointer) noexcept
 Takes ownership of a pointer. More...
 
 basic_unique_ptr (pointer pPointer, deleter_type &deleter) noexcept
 Takes ownership of a pointer. More...
 
 basic_unique_ptr (pointer pPointer, const deleter_type &deleter) noexcept
 Takes ownership of a pointer. More...
 
 basic_unique_ptr (pointer pPointer, deleter_type &&deleter) noexcept
 Takes ownership of a pointer. More...
 
 basic_unique_ptr (self_type &&other)
 Move constructor. More...
 
template<typename U , class UAllocator = memory::default_allocator, class UDeleter = memory::default_delete<U, UAllocator>>
 basic_unique_ptr (basic_unique_ptr< U, UAllocator, UDeleter > &&other) noexcept
 Converting constructor from another type. More...
 
 ~basic_unique_ptr () noexcept
 Destructor, invokes the deleter if the stored pointer is not null. More...
 
self_typeoperator= (self_type &&other) noexcept
 Move assignment operator. More...
 
template<typename U , class UAllocator = memory::default_allocator, class UDeleter = memory::default_delete<U, UAllocator>>
self_typeoperator= (basic_unique_ptr< U, UAllocator, UDeleter > &&other) noexcept
 Move assignment operator. More...
 
pointer release () noexcept
 Release ownership of any stored pointer. More...
 
void reset (pointer pPtr) noexcept
 Replace the stored pointer. More...
 
void swap (self_type &other) noexcept
 Exchange the pointer and deleter with another object. More...
 
pointer get () const noexcept
 Get the stored pointer. More...
 
deleter_typeget_deleter () noexcept
 Get a reference to the stored deleter. More...
 
const deleter_typeget_deleter () const noexcept
 Get a reference to the stored deleter. More...
 
reference operator* () const
 Return the stored pointer as reference. More...
 
pointer operator-> () const noexcept
 Return the stored pointer. More...
 
 operator bool () const noexcept
 Is the stored pointer not null? More...
 
- Public Member Functions inherited from mn::only_move_tag< void >
 only_move_tag ()=default
 
 only_move_tag (this_type &&other)=default
 
 only_move_tag (const this_type &)=delete
 
this_typeoperator= (const this_type &)=delete
 
this_typeoperator= (this_type &&other)=default
 

Private Attributes

pointer m_ptr
 
deleter_typem_refDeleter
 

Detailed Description

template<typename T, class TAllocator = memory::default_allocator, class TDeleter = memory::default_delete<T, TAllocator>>
class mn::pointer::basic_unique_ptr< T, TAllocator, TDeleter >

A simple unique_ptr, for a single object.

Template Parameters
TThe type of the stored pointer.
TAllocatorThe type of the using allocator, for the deleter.
TDeleterThe type of the using deleter.

Member Typedef Documentation

◆ allotor_type

template<typename T , class TAllocator = memory::default_allocator, class TDeleter = memory::default_delete<T, TAllocator>>
using mn::pointer::basic_unique_ptr< T, TAllocator, TDeleter >::allotor_type = TAllocator

◆ const_pointer

template<typename T , class TAllocator = memory::default_allocator, class TDeleter = memory::default_delete<T, TAllocator>>
using mn::pointer::basic_unique_ptr< T, TAllocator, TDeleter >::const_pointer = const T*

◆ const_reference

template<typename T , class TAllocator = memory::default_allocator, class TDeleter = memory::default_delete<T, TAllocator>>
using mn::pointer::basic_unique_ptr< T, TAllocator, TDeleter >::const_reference = const T&

◆ deleter_type

template<typename T , class TAllocator = memory::default_allocator, class TDeleter = memory::default_delete<T, TAllocator>>
using mn::pointer::basic_unique_ptr< T, TAllocator, TDeleter >::deleter_type = TDeleter

◆ pointer

template<typename T , class TAllocator = memory::default_allocator, class TDeleter = memory::default_delete<T, TAllocator>>
using mn::pointer::basic_unique_ptr< T, TAllocator, TDeleter >::pointer = T*

◆ reference

template<typename T , class TAllocator = memory::default_allocator, class TDeleter = memory::default_delete<T, TAllocator>>
using mn::pointer::basic_unique_ptr< T, TAllocator, TDeleter >::reference = T&

◆ self_type

template<typename T , class TAllocator = memory::default_allocator, class TDeleter = memory::default_delete<T, TAllocator>>
using mn::pointer::basic_unique_ptr< T, TAllocator, TDeleter >::self_type = basic_unique_ptr<value_type, allotor_type, deleter_type>

◆ value_type

template<typename T , class TAllocator = memory::default_allocator, class TDeleter = memory::default_delete<T, TAllocator>>
using mn::pointer::basic_unique_ptr< T, TAllocator, TDeleter >::value_type = T

Constructor & Destructor Documentation

◆ basic_unique_ptr() [1/8]

template<typename T , class TAllocator = memory::default_allocator, class TDeleter = memory::default_delete<T, TAllocator>>
constexpr mn::pointer::basic_unique_ptr< T, TAllocator, TDeleter >::basic_unique_ptr ( )
inlineconstexprnoexcept

Constructor a basic_unique_ptr that owns nothing.

◆ basic_unique_ptr() [2/8]

template<typename T , class TAllocator = memory::default_allocator, class TDeleter = memory::default_delete<T, TAllocator>>
constexpr mn::pointer::basic_unique_ptr< T, TAllocator, TDeleter >::basic_unique_ptr ( nullptr_t  )
inlineconstexprnoexcept

Creates a unique_ptr that owns nothing.

◆ basic_unique_ptr() [3/8]

template<typename T , class TAllocator = memory::default_allocator, class TDeleter = memory::default_delete<T, TAllocator>>
mn::pointer::basic_unique_ptr< T, TAllocator, TDeleter >::basic_unique_ptr ( pointer  pPointer)
inlineexplicitnoexcept

Takes ownership of a pointer.

◆ basic_unique_ptr() [4/8]

template<typename T , class TAllocator = memory::default_allocator, class TDeleter = memory::default_delete<T, TAllocator>>
mn::pointer::basic_unique_ptr< T, TAllocator, TDeleter >::basic_unique_ptr ( pointer  pPointer,
deleter_type deleter 
)
inlinenoexcept

Takes ownership of a pointer.

Parameters
pPointerA pointer to an object of element_type
deleterA reference to a deleter.

◆ basic_unique_ptr() [5/8]

template<typename T , class TAllocator = memory::default_allocator, class TDeleter = memory::default_delete<T, TAllocator>>
mn::pointer::basic_unique_ptr< T, TAllocator, TDeleter >::basic_unique_ptr ( pointer  pPointer,
const deleter_type deleter 
)
inlinenoexcept

Takes ownership of a pointer.

Parameters
pPointerA pointer to an object of element_type
deleterA reference to a deleter.

◆ basic_unique_ptr() [6/8]

template<typename T , class TAllocator = memory::default_allocator, class TDeleter = memory::default_delete<T, TAllocator>>
mn::pointer::basic_unique_ptr< T, TAllocator, TDeleter >::basic_unique_ptr ( pointer  pPointer,
deleter_type &&  deleter 
)
inlinenoexcept

Takes ownership of a pointer.

Parameters
pPointerA pointer to an object of element_type
deleterAn rvalue reference to a deleter.

◆ basic_unique_ptr() [7/8]

template<typename T , class TAllocator = memory::default_allocator, class TDeleter = memory::default_delete<T, TAllocator>>
mn::pointer::basic_unique_ptr< T, TAllocator, TDeleter >::basic_unique_ptr ( self_type &&  other)
inline

Move constructor.

◆ basic_unique_ptr() [8/8]

template<typename T , class TAllocator = memory::default_allocator, class TDeleter = memory::default_delete<T, TAllocator>>
template<typename U , class UAllocator = memory::default_allocator, class UDeleter = memory::default_delete<U, UAllocator>>
mn::pointer::basic_unique_ptr< T, TAllocator, TDeleter >::basic_unique_ptr ( basic_unique_ptr< U, UAllocator, UDeleter > &&  other)
inlinenoexcept

Converting constructor from another type.

◆ ~basic_unique_ptr()

template<typename T , class TAllocator = memory::default_allocator, class TDeleter = memory::default_delete<T, TAllocator>>
mn::pointer::basic_unique_ptr< T, TAllocator, TDeleter >::~basic_unique_ptr ( )
inlinenoexcept

Destructor, invokes the deleter if the stored pointer is not null.

Member Function Documentation

◆ get()

template<typename T , class TAllocator = memory::default_allocator, class TDeleter = memory::default_delete<T, TAllocator>>
pointer mn::pointer::basic_unique_ptr< T, TAllocator, TDeleter >::get ( void  ) const
inlinenoexcept

Get the stored pointer.

Returns
The stored pointer.

◆ get_deleter() [1/2]

template<typename T , class TAllocator = memory::default_allocator, class TDeleter = memory::default_delete<T, TAllocator>>
const deleter_type& mn::pointer::basic_unique_ptr< T, TAllocator, TDeleter >::get_deleter ( ) const
inlinenoexcept

Get a reference to the stored deleter.

Returns
The reference to the stored deleter.

◆ get_deleter() [2/2]

template<typename T , class TAllocator = memory::default_allocator, class TDeleter = memory::default_delete<T, TAllocator>>
deleter_type& mn::pointer::basic_unique_ptr< T, TAllocator, TDeleter >::get_deleter ( )
inlinenoexcept

Get a reference to the stored deleter.

Returns
The reference to the stored deleter.

◆ operator bool()

template<typename T , class TAllocator = memory::default_allocator, class TDeleter = memory::default_delete<T, TAllocator>>
mn::pointer::basic_unique_ptr< T, TAllocator, TDeleter >::operator bool ( ) const
inlineexplicitnoexcept

Is the stored pointer not null?

Returns
true if the stored pointer is not null.

◆ operator*()

template<typename T , class TAllocator = memory::default_allocator, class TDeleter = memory::default_delete<T, TAllocator>>
reference mn::pointer::basic_unique_ptr< T, TAllocator, TDeleter >::operator* ( void  ) const
inline

Return the stored pointer as reference.

◆ operator->()

template<typename T , class TAllocator = memory::default_allocator, class TDeleter = memory::default_delete<T, TAllocator>>
pointer mn::pointer::basic_unique_ptr< T, TAllocator, TDeleter >::operator-> ( ) const
inlinenoexcept

Return the stored pointer.

◆ operator=() [1/2]

template<typename T , class TAllocator = memory::default_allocator, class TDeleter = memory::default_delete<T, TAllocator>>
template<typename U , class UAllocator = memory::default_allocator, class UDeleter = memory::default_delete<U, UAllocator>>
self_type& mn::pointer::basic_unique_ptr< T, TAllocator, TDeleter >::operator= ( basic_unique_ptr< U, UAllocator, UDeleter > &&  other)
inlinenoexcept

Move assignment operator.

Parameters
otherThe object to transfer ownership from.
Returns
this

◆ operator=() [2/2]

template<typename T , class TAllocator = memory::default_allocator, class TDeleter = memory::default_delete<T, TAllocator>>
self_type& mn::pointer::basic_unique_ptr< T, TAllocator, TDeleter >::operator= ( self_type &&  other)
inlinenoexcept

Move assignment operator.

Parameters
otherThe object to transfer ownership from.
Returns
this

◆ release()

template<typename T , class TAllocator = memory::default_allocator, class TDeleter = memory::default_delete<T, TAllocator>>
pointer mn::pointer::basic_unique_ptr< T, TAllocator, TDeleter >::release ( )
inlinenoexcept

Release ownership of any stored pointer.

Returns
The stored pointer, bevor it set to null.

◆ reset()

template<typename T , class TAllocator = memory::default_allocator, class TDeleter = memory::default_delete<T, TAllocator>>
void mn::pointer::basic_unique_ptr< T, TAllocator, TDeleter >::reset ( pointer  pPtr)
inlinenoexcept

Replace the stored pointer.

◆ swap()

template<typename T , class TAllocator = memory::default_allocator, class TDeleter = memory::default_delete<T, TAllocator>>
void mn::pointer::basic_unique_ptr< T, TAllocator, TDeleter >::swap ( self_type other)
inlinenoexcept

Exchange the pointer and deleter with another object.

Member Data Documentation

◆ m_ptr

template<typename T , class TAllocator = memory::default_allocator, class TDeleter = memory::default_delete<T, TAllocator>>
pointer mn::pointer::basic_unique_ptr< T, TAllocator, TDeleter >::m_ptr
private

◆ m_refDeleter

template<typename T , class TAllocator = memory::default_allocator, class TDeleter = memory::default_delete<T, TAllocator>>
deleter_type& mn::pointer::basic_unique_ptr< T, TAllocator, TDeleter >::m_refDeleter
private

The documentation for this class was generated from the following file: