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

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()

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.

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.


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