OpenTTD: AutoFreePtr< T > Class Template Reference

OpenTTD

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- Data Structures
- Class Hierarchy
- Data Fields

Public Member Functions | Private Attributes
AutoFreePtr< T > Class Template Reference

A smart pointer class that free()'s the pointer on destruction. More...

`#include <alloc_type.hpp>`

## Public Member Functions
| AutoFreePtr (T *ptr)
void | Assign (T *ptr)
| Take ownership of a new pointer and free the old one if needed.
T * | operator-> ()
| Dereference pointer.
const T * | operator-> () const
| Dereference pointer.
| operator T * ()
| Cast to underlaying regular pointer.
| operator const T * () const
| Cast to underlaying regular pointer.

## Private Attributes
T * | ptr
| Stored pointer.

## Detailed Description

### template<typename T>
class AutoFreePtr< T >

A smart pointer class that free()'s the pointer on destruction.

Template Parameters

  T | Storage type.

Definition at line 188 of file alloc_type.hpp.

## Member Function Documentation

template<typename T>

void AutoFreePtr< T >::Assign | ( | T * | ptr | ) |
| inline

Take ownership of a new pointer and free the old one if needed.

Parameters

  ptr | NEw pointer.

Definition at line 200 of file alloc_type.hpp.

References free(), and AutoFreePtr< T >::ptr.

template<typename T>

AutoFreePtr< T >::operator const T * | ( |  | ) | const
| inline

Cast to underlaying regular pointer.

Definition at line 214 of file alloc_type.hpp.

References AutoFreePtr< T >::ptr.

template<typename T>

AutoFreePtr< T >::operator T * | ( |  | ) |
| inline

Cast to underlaying regular pointer.

Definition at line 212 of file alloc_type.hpp.

References AutoFreePtr< T >::ptr.

template<typename T>

T* AutoFreePtr< T >::operator-> | ( |  | ) |
| inline

Dereference pointer.

Definition at line 207 of file alloc_type.hpp.

References AutoFreePtr< T >::ptr.

template<typename T>

const T* AutoFreePtr< T >::operator-> | ( |  | ) | const
| inline

Dereference pointer.

Definition at line 209 of file alloc_type.hpp.

References AutoFreePtr< T >::ptr.

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

- src/core/alloc_type.hpp