cppcore
A small, portable C++ core library
Loading...
Searching...
No Matches
cppcore::TDefaultAllocator< T > Class Template Reference

This class implements the default allocator used by all container classes of the cppcore library. More...

#include <TDefaultAllocator.h>

Public Member Functions

 TDefaultAllocator ()=default
 The default class constructor.
 ~TDefaultAllocator ()=default
 The class destructor.
T * alloc (size_t size)
 Will allocate the number of insances.
void release (T *ptr)
 Will release the last item from the stack.
void reserve (size_t size)
 Will prereserve the number of instances.
void clear ()
 Will clear the whole memory, all used data will be marked as invalid.
size_t capacity () const
 Returns the number of allocated instances on the stack.
size_t reservedMem () const
 Returns the allocated memory in bytes.
size_t freeMem () const
 Returns the free memory in bytes.
void dumpAllocations (std::string &allocs)
 Will dump a statistic overview into the given string.

Detailed Description

template<class T>
class cppcore::TDefaultAllocator< T >

This class implements the default allocator used by all container classes of the cppcore library.

Definition at line 37 of file TDefaultAllocator.h.

Constructor & Destructor Documentation

◆ TDefaultAllocator()

template<class T>
cppcore::TDefaultAllocator< T >::TDefaultAllocator ( )
default

The default class constructor.

Referenced by ~TDefaultAllocator().

◆ ~TDefaultAllocator()

template<class T>
cppcore::TDefaultAllocator< T >::~TDefaultAllocator ( )
default

The class destructor.

References TDefaultAllocator().

Member Function Documentation

◆ alloc()

template<class T>
T * cppcore::TDefaultAllocator< T >::alloc ( size_t size)
inline

Will allocate the number of insances.

Parameters
[in]sizeSize of instances to allocate.
Returns
Pointer showing to the new instance or nullptr if not possible.

Definition at line 83 of file TDefaultAllocator.h.

◆ capacity()

template<class T>
size_t cppcore::TDefaultAllocator< T >::capacity ( ) const
inline

Returns the number of allocated instances on the stack.

Returns
The number of allocated instance.

Definition at line 103 of file TDefaultAllocator.h.

◆ clear()

template<class T>
void cppcore::TDefaultAllocator< T >::clear ( )
inline

Will clear the whole memory, all used data will be marked as invalid.

Definition at line 98 of file TDefaultAllocator.h.

◆ dumpAllocations()

template<class T>
void cppcore::TDefaultAllocator< T >::dumpAllocations ( std::string & allocs)
inline

Will dump a statistic overview into the given string.

Parameters
allocs[inout] The string to hold the allocation statistic.

Definition at line 118 of file TDefaultAllocator.h.

◆ freeMem()

template<class T>
size_t cppcore::TDefaultAllocator< T >::freeMem ( ) const
inline

Returns the free memory in bytes.

Returns
The free memory in bytes.

Definition at line 113 of file TDefaultAllocator.h.

◆ release()

template<class T>
void cppcore::TDefaultAllocator< T >::release ( T * ptr)
inline

Will release the last item from the stack.

A basic check will be performed to ensure that it is the correct item.

Parameters
ptr[in] The pointer to validate.

Definition at line 88 of file TDefaultAllocator.h.

◆ reserve()

template<class T>
void cppcore::TDefaultAllocator< T >::reserve ( size_t size)
inline

Will prereserve the number of instances.

Parameters
[in]sizeNUmber, not used here.

Definition at line 93 of file TDefaultAllocator.h.

◆ reservedMem()

template<class T>
size_t cppcore::TDefaultAllocator< T >::reservedMem ( ) const
inline

Returns the allocated memory in bytes.

Returns
The allocated memory in bytes.

Definition at line 108 of file TDefaultAllocator.h.


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