Sources Pipelines Documentation

Allocators  
Allocators [master] Documentation

Motivation

This repository provides implementation of composable allocators described by Andrei Alexandrescu on CppCon 2015

Following allocators have been implemented:

Allocators which maybe supplemented in the future:

Usage

All header files composing on this library are located in src/include/boost/memory. It suffices to clone this repository and add src/include to the list of include directories minded during compilation of your project. For example look into CMakeLists.txt from composition sample.

Implemented allocators then can be used in the code after inclusion of boost/memory.hpp header:

#include <boost/memory.hpp>
...

using namespace boost::memory;

stack_allocator<1024> allocator;
auto block = allocator.allocate(512);
...

The library defines replacement operators new, new array, delete and delete array. All of them are activated when boost/memory/operators.hpp is included. Behavior of the operators can be controlled with macros:

Build

The library is purely header based, as such it doesn't require compilation for use in third party project. Thus use of c++ 14 compatible compiler is necessary.

In order to build unit tests and samples, cmake (3.2 or newer), internet access and all google tests framework prerequisites are required. Any C++ 14 compatible compiler should do, tho the project has been successfully build and tested only on OS X (both Xcode and clang) and Linux (Ubuntu 16.04) with clang 3.9.

To build:

  1. Clone this repository
     $ git clone https://bitbucket.org/lukaszlaszko/allocators.git 
    
  2. Configure with cmake
     $ mkdir bin
     $ cd bin
     $ cmake ..
    
  3. Build with cmake
     $ cmake --build . --target all
    
  4. Run unit tests
     $ ctest --verbose
    

Latest bitbucket build results can be observed under this link.