Disk ARchive 2.7.16
Full featured and portable backup and archiving tool
Public Member Functions | Private Attributes | List of all members
libdar::smart_pointer< T > Class Template Reference

smart pointer class to be used to automagically manage multiple time pointed to address More...

#include <smart_pointer.hpp>

+ Inheritance diagram for libdar::smart_pointer< T >:
+ Collaboration diagram for libdar::smart_pointer< T >:

Public Member Functions

 smart_pointer ()
 creates a smart_pointer equivalent to a pointer to NULL More...
 
 smart_pointer (T *arg)
 creates a smart_pointer pointing to an allocated memory More...
 
 smart_pointer (const smart_pointer &ref)
 copy constructor More...
 
 smart_pointer (smart_pointer &&ref) noexcept
 move constructor More...
 
 ~smart_pointer ()
 destructor More...
 
smart_pointeroperator= (const smart_pointer &ref)
 assignment operator More...
 
smart_pointeroperator= (smart_pointer &&ref)
 move assignment operator More...
 
const smart_pointerassign (T *arg)
 assignment operator from a base type pointer (not from a smart_pointer) More...
 
T & operator* () const
 content-of operator More...
 
T * operator-> () const
 content-of field operator (when the pointed to object is a struct or class More...
 
bool is_null () const
 return whether the smart_pointer is pointing to nullptr More...
 

Private Attributes

smart_node< T > * ptr
 

Detailed Description

template<class T>
class libdar::smart_pointer< T >

smart pointer class to be used to automagically manage multiple time pointed to address

this class tend to mimic normal pointer with the additional feature of automatically releasing the pointed to object when no more smart_pointer point to it. In consequence:

Definition at line 78 of file smart_pointer.hpp.

Constructor & Destructor Documentation

◆ smart_pointer() [1/4]

template<class T >
libdar::smart_pointer< T >::smart_pointer ( )
inline

creates a smart_pointer equivalent to a pointer to NULL

Definition at line 82 of file smart_pointer.hpp.

◆ smart_pointer() [2/4]

template<class T >
libdar::smart_pointer< T >::smart_pointer ( T *  arg)
inline

creates a smart_pointer pointing to an allocated memory

Parameters
[in]argis the address of the allocated memory the smart_pointer must manage, nullptr is allowed and lead to the same behavior as the constructor without argument
Note
the given pointed to object, passes under the responsibility of the smart_pointer and must not be deleted any further

Definition at line 90 of file smart_pointer.hpp.

◆ smart_pointer() [3/4]

template<class T >
libdar::smart_pointer< T >::smart_pointer ( const smart_pointer< T > &  ref)
inline

copy constructor

Definition at line 104 of file smart_pointer.hpp.

◆ smart_pointer() [4/4]

template<class T >
libdar::smart_pointer< T >::smart_pointer ( smart_pointer< T > &&  ref)
inlinenoexcept

move constructor

Definition at line 107 of file smart_pointer.hpp.

◆ ~smart_pointer()

template<class T >
libdar::smart_pointer< T >::~smart_pointer ( )
inline

destructor

Definition at line 110 of file smart_pointer.hpp.

Member Function Documentation

◆ assign()

template<class T >
const smart_pointer & libdar::smart_pointer< T >::assign ( T *  arg)
inline

assignment operator from a base type pointer (not from a smart_pointer)

Note
choice has been not to overload/use operator= to avoid risk of error that would lead to create independent smart_pointer sets accidentally

Definition at line 151 of file smart_pointer.hpp.

◆ is_null()

template<class T >
bool libdar::smart_pointer< T >::is_null ( ) const
inline

return whether the smart_pointer is pointing to nullptr

Definition at line 165 of file smart_pointer.hpp.

Referenced by libdar::cat_entree::get_compressor_layer(), libdar::cat_entree::get_escape_layer(), and libdar::cat_entree::get_pile().

◆ operator*()

template<class T >
T & libdar::smart_pointer< T >::operator* ( ) const
inline

content-of operator

Definition at line 159 of file smart_pointer.hpp.

◆ operator->()

template<class T >
T * libdar::smart_pointer< T >::operator-> ( ) const
inline

content-of field operator (when the pointed to object is a struct or class

Definition at line 162 of file smart_pointer.hpp.

◆ operator=() [1/2]

template<class T >
smart_pointer & libdar::smart_pointer< T >::operator= ( const smart_pointer< T > &  ref)
inline

assignment operator

Definition at line 113 of file smart_pointer.hpp.

◆ operator=() [2/2]

template<class T >
smart_pointer & libdar::smart_pointer< T >::operator= ( smart_pointer< T > &&  ref)
inline

move assignment operator

Definition at line 134 of file smart_pointer.hpp.

Member Data Documentation

◆ ptr

template<class T >
smart_node<T>* libdar::smart_pointer< T >::ptr
private

Definition at line 168 of file smart_pointer.hpp.


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