sparrow 0.3.0
Loading...
Searching...
No Matches
sparrow::cloning_ptr< T > Class Template Reference

Smart pointer behaving like a copiable std::unique_ptr. More...

#include <memory.hpp>

Public Types

using self_type = cloning_ptr<T>
 
using pointer = typename internal_pointer::pointer
 
using element_type = typename internal_pointer::element_type
 

Public Member Functions

constexpr cloning_ptr () noexcept=default
 
constexpr cloning_ptr (std::nullptr_t) noexcept
 
constexpr cloning_ptr (pointer p) noexcept
 
constexpr ~cloning_ptr ()=default
 
constexpr cloning_ptr (const self_type &rhs) noexcept
 
constexpr cloning_ptr (self_type &&rhs) noexcept=default
 
template<clonable U>
requires std::convertible_to<U*, T*>
constexpr cloning_ptr (const cloning_ptr< U > &rhs) noexcept
 
template<clonable U>
requires std::convertible_to<U*, T*>
constexpr cloning_ptr (cloning_ptr< U > &&rhs) noexcept
 
constexpr self_typeoperator= (const self_type &) noexcept
 
constexpr self_typeoperator= (self_type &&) noexcept=default
 
constexpr self_typeoperator= (std::nullptr_t) noexcept
 
template<clonable U>
requires std::convertible_to<U*, T*>
constexpr self_typeoperator= (const cloning_ptr< U > &rhs) noexcept
 
template<clonable U>
requires std::convertible_to<U*, T*>
constexpr self_typeoperator= (cloning_ptr< U > &&rhs) noexcept
 
constexpr pointer release () noexcept
 
constexpr void reset (pointer ptr=pointer()) noexcept
 
void swap (self_type &) noexcept
 
constexpr pointer get () const noexcept
 
constexpr operator bool () const noexcept
 
constexpr std::add_lvalue_reference_t< T > operator* () const noexcept(noexcept(*std::declval< pointer >()))
 
constexpr pointer operator-> () const noexcept
 
template<clonable U>
requires std::convertible_to<U*, T*>
constexpr auto operator= (const cloning_ptr< U > &rhs) noexcept -> self_type &
 
template<clonable U>
requires std::convertible_to<U*, T*>
constexpr auto operator= (cloning_ptr< U > &&rhs) noexcept -> self_type &
 

Detailed Description

template<clonable T>
class sparrow::cloning_ptr< T >

Smart pointer behaving like a copiable std::unique_ptr.

cloning_ptr owns and manages another object through a pointer, like std::unique_ptr. The difference with std::unique_ptr is that cloning_ptrcalls the clone method of the managed object upon copy. Therefore,cloning_ptris meant to be used with hierarchies of classes which provide aclone` method which returns a unique pointer.

Template Parameters
TThe type of the object managed by the cloning_ptr. It must satisfy the clonable concept.

Definition at line 126 of file memory.hpp.

Member Typedef Documentation

◆ element_type

template<clonable T>
using sparrow::cloning_ptr< T >::element_type = typename internal_pointer::element_type

Definition at line 134 of file memory.hpp.

◆ pointer

template<clonable T>
using sparrow::cloning_ptr< T >::pointer = typename internal_pointer::pointer

Definition at line 133 of file memory.hpp.

◆ self_type

template<clonable T>
using sparrow::cloning_ptr< T >::self_type = cloning_ptr<T>

Definition at line 132 of file memory.hpp.

Constructor & Destructor Documentation

◆ cloning_ptr() [1/7]

template<clonable T>
sparrow::cloning_ptr< T >::cloning_ptr ( )
constexprdefaultnoexcept
Here is the caller graph for this function:

◆ cloning_ptr() [2/7]

template<clonable T>
sparrow::cloning_ptr< T >::cloning_ptr ( std::nullptr_t )
constexprnoexcept

Definition at line 334 of file memory.hpp.

◆ cloning_ptr() [3/7]

template<clonable T>
sparrow::cloning_ptr< T >::cloning_ptr ( pointer p)
explicitconstexprnoexcept

Definition at line 340 of file memory.hpp.

◆ ~cloning_ptr()

template<clonable T>
sparrow::cloning_ptr< T >::~cloning_ptr ( )
constexprdefault

◆ cloning_ptr() [4/7]

template<clonable T>
sparrow::cloning_ptr< T >::cloning_ptr ( const self_type & rhs)
constexprnoexcept

Definition at line 346 of file memory.hpp.

Here is the call graph for this function:

◆ cloning_ptr() [5/7]

template<clonable T>
sparrow::cloning_ptr< T >::cloning_ptr ( self_type && rhs)
constexprdefaultnoexcept

◆ cloning_ptr() [6/7]

template<clonable T>
requires std::convertible_to<U*, T*>
template<clonable U>
requires std::convertible_to<U*, T*>
sparrow::cloning_ptr< T >::cloning_ptr ( const cloning_ptr< U > & rhs)
constexprnoexcept

Definition at line 354 of file memory.hpp.

Here is the call graph for this function:

◆ cloning_ptr() [7/7]

template<clonable T>
requires std::convertible_to<U*, T*>
template<clonable U>
requires std::convertible_to<U*, T*>
sparrow::cloning_ptr< T >::cloning_ptr ( cloning_ptr< U > && rhs)
constexprnoexcept

Definition at line 362 of file memory.hpp.

Here is the call graph for this function:

Member Function Documentation

◆ get()

template<clonable T>
auto sparrow::cloning_ptr< T >::get ( ) const
nodiscardconstexprnoexcept

Definition at line 419 of file memory.hpp.

Here is the caller graph for this function:

◆ operator bool()

template<clonable T>
sparrow::cloning_ptr< T >::operator bool ( ) const
explicitconstexprnoexcept

Definition at line 425 of file memory.hpp.

Here is the call graph for this function:

◆ operator*()

template<clonable T>
std::add_lvalue_reference_t< T > sparrow::cloning_ptr< T >::operator* ( ) const
nodiscardconstexprnoexcept

Definition at line 431 of file memory.hpp.

Here is the call graph for this function:

◆ operator->()

template<clonable T>
auto sparrow::cloning_ptr< T >::operator-> ( ) const
nodiscardconstexprnoexcept

Definition at line 438 of file memory.hpp.

Here is the call graph for this function:

◆ operator=() [1/7]

template<clonable T>
template<clonable U>
requires std::convertible_to<U*, T*>
self_type & sparrow::cloning_ptr< T >::operator= ( cloning_ptr< U > && rhs)
constexprnoexcept

◆ operator=() [2/7]

template<clonable T>
template<clonable U>
requires std::convertible_to<U*, T*>
auto sparrow::cloning_ptr< T >::operator= ( cloning_ptr< U > && rhs) -> self_type&
constexprnoexcept

Definition at line 393 of file memory.hpp.

◆ operator=() [3/7]

template<clonable T>
template<clonable U>
requires std::convertible_to<U*, T*>
self_type & sparrow::cloning_ptr< T >::operator= ( const cloning_ptr< U > & rhs)
constexprnoexcept

◆ operator=() [4/7]

template<clonable T>
template<clonable U>
requires std::convertible_to<U*, T*>
auto sparrow::cloning_ptr< T >::operator= ( const cloning_ptr< U > & rhs) -> self_type&
constexprnoexcept

Definition at line 384 of file memory.hpp.

◆ operator=() [5/7]

template<clonable T>
auto sparrow::cloning_ptr< T >::operator= ( const self_type & rhs)
constexprnoexcept

Definition at line 368 of file memory.hpp.

◆ operator=() [6/7]

template<clonable T>
self_type & sparrow::cloning_ptr< T >::operator= ( self_type && )
constexprdefaultnoexcept

◆ operator=() [7/7]

template<clonable T>
auto sparrow::cloning_ptr< T >::operator= ( std::nullptr_t )
constexprnoexcept

Definition at line 375 of file memory.hpp.

Here is the call graph for this function:

◆ release()

template<clonable T>
auto sparrow::cloning_ptr< T >::release ( )
constexprnoexcept

Definition at line 400 of file memory.hpp.

◆ reset()

template<clonable T>
void sparrow::cloning_ptr< T >::reset ( pointer ptr = pointer())
constexprnoexcept

Definition at line 406 of file memory.hpp.

Here is the caller graph for this function:

◆ swap()

template<clonable T>
void sparrow::cloning_ptr< T >::swap ( self_type & other)
noexcept

Definition at line 412 of file memory.hpp.

Here is the call graph for this function:

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