Boost C++ Libraries of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of boost. Click here for the latest Boost documentation.

Template simple_stack_allocator< size_t, size_t, size_t >

Boost.Context provides the class simple_stack_allocator which models the StackAllocator concept concept. The template arguments define the limits for the stack size. The class simply allocates memory on the heap via calloc() - in contrast to guarded_stack_allocator no guard page is appended.

[Important] Important

The user is responsible for valid stack limits (e.g. maximum, minimum and default stacksize.

template< size_t Max, size_t Default, size_t Min >
class simple_stack_allocator
    static std::size_t maximum_stacksize();

    static std::size_t default_stacksize();

    static std::size_t minimum_stacksize();

    void * allocate( std::size_t size);

    void deallocate( void * sp, std::size_t size);
static std::size_t maximum_stacksize()


Returns the maximum size in bytes of stack defined by the first tempalte argument.

static std::size_t default_stacksize()


Returns a default stack size in bytes defined by the second template argument.

static std::size_t minimum_stacksize()


Returns the minimum size in bytes of stack defined by the third template argument.

void * allocate( std::size_t size)


minimum_stacksize() > size and maximum_stacksize() < size.


Allocates memory of size bytes (memory is set to NULL).


Returns pointer to the start address of the new stack. Depending on the architecture the stack grows downwards/upwards the returned address is the highest/lowest address of the stack.

void deallocate( void * sp, std::size_t size)


sp is valid, minimum_stacksize() > size and maximum_stacksize() < size.


Deallocates the stack space.