tracked_block_allocator< Tracker, BlockOrRawAllocator > Class Template Reference
Adapters and Wrappers

## Detailed Description

template<class Tracker, class BlockOrRawAllocator>
class foonathan::memory::tracked_block_allocator< Tracker, BlockOrRawAllocator >

A BlockAllocator adapter that tracks another allocator using a tracker.

It wraps another BlockAllocator and calls the tracker function before forwarding to it. The class can then be used anywhere a BlockAllocator is required and the memory usage will be tracked.
It will only call the `on_allocator_growth()` and `on_allocator_shrinking()` tracking functions, since a BlockAllocator is normally used inside higher allocators only.

## Typedefs

using | allocator_type = make_block_allocator_t< BlockOrRawAllocator >
using | tracker = Tracker

## Member Functions

template<typename... Args>
| tracked_block_allocator (std::size_t block_size, tracker t, Args &&... args)
memory_block | allocate_block ()
void | deallocate_block (memory_block block) noexcept
std::size_t | next_block_size () const noexcept
| tracked_block_allocator (tracker t={}) noexcept
| tracked_block_allocator (tracker t, allocator_type &&alloc) noexcept
allocator_type & | get_allocator () noexcept
const allocator_type & | get_allocator () const noexcept
tracker & | get_tracker () noexcept
const tracker & | get_tracker () const noexcept

## Constructors

## tracked_block_allocator() [1/3]

template<class Tracker , class BlockOrRawAllocator >

tracked_block_allocator | ( | tracker | t = `{}` | ) |

explicit noexcept

Effects:
  Creates it by giving it a tracker and the tracked RawAllocator. It will embed both objects.

## tracked_block_allocator() [2/3]

template<class Tracker , class BlockOrRawAllocator >

tracked_block_allocator | ( | tracker | t,
|  | allocator_type && | alloc
| ) |  |

noexcept

Effects:
  Creates it by giving it a tracker and the tracked RawAllocator. It will embed both objects.

## tracked_block_allocator() [3/3]

template<class Tracker , class BlockOrRawAllocator >
template<typename... Args>

tracked_block_allocator | ( | std::size_t | block_size,
|  | tracker | t,
|  | Args &&... | args
| ) |  |

Effects:
  Creates it in the form required by the concept. The allocator will be constructed using `block_size` and `args`.

## Member Functions

## allocate_block()

template<class Tracker , class BlockOrRawAllocator >

memory_block allocate_block | ( |  | ) |

Effects:
  Calls `Tracker::on_allocator_growth()` after forwarding to the allocator.

Returns:
  The block as the returned by the allocator.

## deallocate_block()

template<class Tracker , class BlockOrRawAllocator >

void deallocate_block | ( | memory_block | block | ) |

noexcept

Effects:
  Calls `Tracker::on_allocator_shrinking()` and forwards to the allocator.

## next_block_size()

template<class Tracker , class BlockOrRawAllocator >

std::size_t next_block_size | ( |  | ) | const

noexcept

Returns:
  The next block size as returned by the allocator.

## get_allocator() [1/2]

template<class Tracker , class BlockOrRawAllocator >

allocator_type & get_allocator | ( |  | ) |

noexcept

Returns:
  A (const) reference to the used allocator.

## get_allocator() [2/2]

template<class Tracker , class BlockOrRawAllocator >

const allocator_type & get_allocator | ( |  | ) | const

noexcept

Returns:
  A (const) reference to the used allocator.

## get_tracker() [1/2]

template<class Tracker , class BlockOrRawAllocator >

tracker & get_tracker | ( |  | ) |

noexcept

Returns:
  A (const) reference to the tracker.

## get_tracker() [2/2]

template<class Tracker , class BlockOrRawAllocator >

const tracker & get_tracker | ( |  | ) | const

noexcept

Returns:
  A (const) reference to the tracker.