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 to view this page for the latest version.

Class fixedsize_stack

Boost.Coroutine2 provides the class fixedsize_stack which models the stack-allocator concept. In contrast to protected_fixedsize_stack it does not append a guard page at the end of each stack. The memory is simply managed by std::malloc() and std::free().

#include <boost/context/fixedsize_stack.hpp>

struct fixedsize_stack {
    fixedsize_stack(std::size_t size = traits_type::default_size());

    stack_context allocate();

    void deallocate( stack_context &);
stack_context allocate()


traits_type::minimum:size() <= size and ! traits_type::is_unbounded() && ( traits_type::maximum:size() >= size).


Allocates memory of at least size Bytes and stores a pointer to the stack and its actual size in sctx. Depending on the architecture (the stack grows downwards/upwards) the stored address is the highest/lowest address of the stack.

void deallocate( stack_context & sctx)


sctx.sp is valid, traits_type::minimum:size() <= sctx.size and ! traits_type::is_unbounded() && ( traits_type::maximum:size() >= sctx.size).


Deallocates the stack space.