Disk ARchive  2.5.9
Full featured and portable backup and archiving tool
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules
Public Member Functions | List of all members
libdar::smart_pointer< T > Class Template Reference

#include <smart_pointer.hpp>

Inherits libdar::on_pool.

Public Member Functions

 smart_pointer ()
 creates a smart_pointer equivalent to a pointer to NULL
 
 smart_pointer (T *arg)
 
 smart_pointer (const smart_pointer &ref)
 copy constructor
 
 ~smart_pointer ()
 destructor
 
const smart_pointeroperator= (const smart_pointer &ref)
 assignment operator
 
const smart_pointerassign (T *arg)
 
T & operator* () const
 content-of operator
 
T * operator-> () const
 content-of filed operator (when the pointed to object is a struct or class
 
bool is_null () const
 return whether the smart_pointer is pointing to nullptr
 
- Public Member Functions inherited from libdar::on_pool
void * operator new (size_t n_byte)
 
void * operator new (size_t n_byte, const std::nothrow_t &nothrow_value)
 
void * operator new[] (size_t n_byte)
 
void * operator new[] (size_t n_byte, const std::nothrow_t &nothrow_value)
 
void * operator new (size_t n_byte, memory_pool *p)
 
void * operator new[] (size_t n_byte, memory_pool *p)
 
void operator delete (void *ptr, memory_pool *p)
 this operator is called by the compiler if an exception is throw from the constructor of the allocated object
 
void operator delete[] (void *ptr, memory_pool *p)
 this operator is called by the compiler if an exception is throw from the constructor of the allocated objects
 
void operator delete (void *ptr)
 this is the usual delete operator, modified to handle allocated objects allocated on a memory pool or not
 
void operator delete[] (void *ptr)
 this is the usual delete[] operator, modified to handle allocated objects allocated on a memory pool or not
 

Additional Inherited Members

- Protected Member Functions inherited from libdar::on_pool
memory_pool * get_pool () const
 
template<class T >
void meta_new (T *&ptr, size_t num)
 
template<class T >
void meta_delete (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 70 of file smart_pointer.hpp.

Constructor & Destructor Documentation

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 82 of file smart_pointer.hpp.

Member Function Documentation

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 126 of file smart_pointer.hpp.


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