| eRPC Generator (erpcgen) Rev. 1.8.1 NXP Semiconductors

- Main Page
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
smart_ptr< T, delete_policy > Class Template Reference

Simple, standard smart pointer class. More...

`#include <smart_ptr.h>`

## Public Types
typedef T | data_type
typedef T * | ptr_type
typedef const T * | const_ptr_type
typedef T & | ref_type
typedef const T & | const_ref_type

## Public Member Functions
| smart_ptr ()
| Default constructor. Initializes with no pointer set.
| smart_ptr (ptr_type p)
| This constructor takes a pointer to the object to be deleted.
| smart_ptr (smart_ptr< T > &&other)
| Move copy constructor.
smart_ptr< T > & | operator= (smart_ptr< T > &&other)
| Move assignment operator.
virtual | ~smart_ptr ()
ptr_type | get ()
| Return the current pointer value.
const_ptr_type | get () const
| Return the const form of the current pointer value.
void | set (ptr_type p)
void | reset ()
| Dissociates any previously set pointer value without deleting it.
void | clear ()
| Dissociates a previously set pointer value, deleting it at the same time.
virtual void | safe_delete ()
Operators
| operator ptr_type ()
| Makes the object transparent as the template type.
| operator const_ptr_type () const
| Const version of the pointer operator.
| operator ref_type ()
| Makes the object transparent as a reference of the template type.
| operator const_ref_type () const
| Const version of the reference operator.
| operator bool () const
| Returns a boolean indicating whether the object has a pointer set or not.
smart_ptr< T > & | operator= (ptr_type p)
| To allow setting the pointer directly. Equivalent to a call to set().
ptr_type | operator-> ()
| Another operator to allow you to treat the object just like a pointer.
const_ptr_type | operator-> () const
| Another operator to allow you to treat the object just like a pointer.

## Protected Member Functions
| smart_ptr (const smart_ptr< T > &)=delete
| Disable the copy constructor.
smart_ptr< T > & | operator= (const smart_ptr< T > &)=delete
| Disable assignment operator.

## Protected Attributes
ptr_type | _p
| The wrapped pointer.

## Detailed Description

### template<typename T, class delete_policy = smart_ptr_delete<T>>
class smart_ptr< T, delete_policy >

Simple, standard smart pointer class.

This class only supports the single-owner paradigm.

## Constructor & Destructor Documentation

template<typename T , class delete_policy = smart_ptr_delete<T>>

virtual smart_ptr< T, delete_policy >::~smart_ptr | ( |  | ) |
| inline virtual

Destructor. If an object (pointer) has been set, it will be deleted. Deletes the object using safe_delete().

## Member Function Documentation

template<typename T , class delete_policy = smart_ptr_delete<T>>

virtual void smart_ptr< T, delete_policy >::safe_delete | ( |  | ) |
| inline virtual

Forces immediate deletion of the object. If you are planning on using this method, think about just using a normal pointer. It probably makes more sense.

template<typename T , class delete_policy = smart_ptr_delete<T>>

void smart_ptr< T, delete_policy >::set | ( | ptr_type | p | ) |
| inline

Change the pointer value, or set if if the default constructor was used. If a pointer had previously been associated with the object, and p is different than that previous pointer, it will be deleted before taking ownership of p. If this is not desired, call reset() beforehand.

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

- smart_ptr.h