Git Product home page Git Product logo

cougar's Introduction

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

cougar's People

Contributors

hosseinmoein avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

cougar's Issues

Stack storage allocators are non-conformant

If you carefully read the requirements for C++ allocator you should conclude that an conforming allocator can not keep the memory within itself. If it keeps it inside it, then what happens if you move the allocator object? What happens if you copy it?

So, an allocator object either has no data at all in it like std::allocator, or it should have some pointer to the memory it serves.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.