| Disk ARchive 2.6.12 Full featured and portable backup and archiving tool

Public Member Functions | Private Attributes | List of all members
libdar::smart_pointer< T > Class Template Reference
Private

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

`#include <smart_pointer.hpp>`

## 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_pointer & | operator= (const smart_pointer &ref)
| assignment operator
smart_pointer & | operator= (smart_pointer &&ref) noexcept
| move assignment operator
const smart_pointer & | assign (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:

- it must not be used to point to non dynamically allocated memory using the "new" operator,
- pointed to memory must never be deleted manually, the last smart_pointer will do it at its destruction time
  Note
    IMPORTANT: smart_pointer cannot be shared between different threads, for efficiency, the smart_pointer nor the pointed to object is protected against concurrent access of several threads

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] | arg | is 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:

- smart_pointer.hpp