Skip to content

Latest commit

 

History

History
74 lines (67 loc) · 3.97 KB

README.md

File metadata and controls

74 lines (67 loc) · 3.97 KB

GitHub C++20 Maintenance

Allocator Cougar

This repo includes several STL conformant allocators. There are two categories of allocators here:

  1. Stack or Static based fixed size allocators. In this category you pre-allocate a fixed size memory block either on the stack or statically. So you can have STL containers that are based on stack memory, for example. One of the side effects of these allocators is to overcome deficiencies in containers like maps and lists where their memory by default is not cache-friendly.
  2. Custom Aligned allocator. This allocator allows you to allocate memory on a custom boundary. This way you can take advantage of SIMD instructions and techniques.

Please see the tester file for code samples.

This is the complete list of allocators in this repo:

// An allocator that allows you to allocate memory for type T on boundary AS.
// The default boundary is system default for type T.
template<typename T, std::size_t AS = 0>
AlignedAllocator
// This allocator pre-allocates memory for MAX_SIZE * sizeof(T) bytes statically.
// It uses best-fit algorithm to find space. Best-fit is a bit slower,
// but it causes considerably less fragmentations
template<typename T, std::size_t MAX_SIZE>
StaticBestFitAllocator
// This allocator pre-allocates memory for MAX_SIZE * sizeof(T) bytes on the stack.
// It uses best-fit algorithm to find space. Best-fit is a bit slower,
// but it causes considerably less fragmentations
template<typename T, std::size_t MAX_SIZE>
StackBestFitAllocator
// This allocator pre-allocates memory for MAX_SIZE * sizeof(T) bytes statically.
// It uses first-fit algorithm to find space. First-fit is faster,
// but it causes more fragmentations
template<typename T, std::size_t MAX_SIZE>
StaticFirstFitAllocator
// This allocator pre-allocates memory for MAX_SIZE * sizeof(T) bytes on the stack.
// It uses first-fit algorithm to find space. First-fit is faster,
// but it causes more fragmentations
template<typename T, std::size_t MAX_SIZE>
StackFirstFitAllocator