binary_segregator< Segregatable, RawAllocator > Class Template Reference
Adapters and Wrappers

## Detailed Description

template<class Segregatable, class RawAllocator>
class foonathan::memory::binary_segregator< Segregatable, RawAllocator >

A RawAllocator that either uses the Segregatable or the other `RawAllocator`.

It is a faster alternative to fallback_allocator that doesn't require a composable allocator and decides about the allocator to use purely with the `Segregatable` based on size and alignment.

## Typedefs

using | segregatable = Segregatable
using | segregatable_allocator_type = typename segregatable::allocator_type
using | fallback_allocator_type = typename allocator_traits< RawAllocator >::allocator_type

## Member Functions

| binary_segregator (segregatable s, fallback_allocator_type fallback=fallback_allocator_type())
void * | allocate_node (std::size_t size, std::size_t alignment)
void | deallocate_node (void *ptr, std::size_t size, std::size_t alignment) noexcept
void * | allocate_array (std::size_t count, std::size_t size, std::size_t alignment)
void | deallocate_array (void *array, std::size_t count, std::size_t size, std::size_t alignment) noexcept
std::size_t | max_node_size () const
std::size_t | max_array_size () const
std::size_t | max_alignemnt () const
segregatable_allocator_type & | get_segregatable_allocator () noexcept
const segregatable_allocator_type & | get_segregatable_allocator () const noexcept
fallback_allocator_type & | get_fallback_allocator () noexcept
const fallback_allocator_type & | get_fallback_allocator () const noexcept

## Constructors

## binary_segregator()

template<class Segregatable , class RawAllocator >

binary_segregator | ( | segregatable | s,
|  | fallback_allocator_type | fallback = `fallback_allocator_type()`
| ) |  |

explicit

Effects:
  Creates it by giving the Segregatable and the RawAllocator.

## Member Functions

## allocate_node()

template<class Segregatable , class RawAllocator >

void * allocate_node | ( | std::size_t | size,
|  | std::size_t | alignment
| ) |  |

Effects:
  Uses the Segregatable to decide which allocator to use. Then forwards to the chosen allocator.

## deallocate_node()

template<class Segregatable , class RawAllocator >

void deallocate_node | ( | void * | ptr,
|  | std::size_t | size,
|  | std::size_t | alignment
| ) |  |

noexcept

Effects:
  Uses the Segregatable to decide which allocator to use. Then forwards to the chosen allocator.

## allocate_array()

template<class Segregatable , class RawAllocator >

void * allocate_array | ( | std::size_t | count,
|  | std::size_t | size,
|  | std::size_t | alignment
| ) |  |

Effects:
  Uses the Segregatable to decide which allocator to use. Then forwards to the chosen allocator.

## deallocate_array()

template<class Segregatable , class RawAllocator >

void deallocate_array | ( | void * | array,
|  | std::size_t | count,
|  | std::size_t | size,
|  | std::size_t | alignment
| ) |  |

noexcept

Effects:
  Uses the Segregatable to decide which allocator to use. Then forwards to the chosen allocator.

## max_node_size()

template<class Segregatable , class RawAllocator >

std::size_t max_node_size | ( |  | ) | const

Returns:
  The maximum value of the fallback.

Note
  It assumes that the fallback will be used for larger allocations, and the `Segregatable` for smaller ones.

## max_array_size()

template<class Segregatable , class RawAllocator >

std::size_t max_array_size | ( |  | ) | const

Returns:
  The maximum value of the fallback.

Note
  It assumes that the fallback will be used for larger allocations, and the `Segregatable` for smaller ones.

## max_alignemnt()

template<class Segregatable , class RawAllocator >

std::size_t max_alignemnt | ( |  | ) | const

Returns:
  The maximum value of the fallback.

Note
  It assumes that the fallback will be used for larger allocations, and the `Segregatable` for smaller ones.

## get_segregatable_allocator() [1/2]

template<class Segregatable , class RawAllocator >

segregatable_allocator_type & get_segregatable_allocator | ( |  | ) |

noexcept

Returns:
  A reference to the segregatable allocator. This is the one primarily used.

## get_segregatable_allocator() [2/2]

template<class Segregatable , class RawAllocator >

const segregatable_allocator_type & get_segregatable_allocator | ( |  | ) | const

noexcept

Returns:
  A reference to the segregatable allocator. This is the one primarily used.

## get_fallback_allocator() [1/2]

template<class Segregatable , class RawAllocator >

fallback_allocator_type & get_fallback_allocator | ( |  | ) |

noexcept

Returns:
  A reference to the fallback allocator. It will be used if the Segregator doesn't want the alloction.

## get_fallback_allocator() [2/2]

template<class Segregatable , class RawAllocator >

const fallback_allocator_type & get_fallback_allocator | ( |  | ) | const

noexcept

Returns:
  A reference to the fallback allocator. It will be used if the Segregator doesn't want the alloction.