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.
C++ Boost

Simple Segregated Storage Implementation


Includes the system headers <cstddef> and <functional>.

Protected Interface


template <typename SizeType = std::size_t>
class simple_segregated_storage
  ... // Public interface

    void * first;
    static void * & nextof(void * const ptr);
    void * find_prev(void * ptr);

void * first;

This data member is the free list. It points to the first chunk in the free list, or is equal to 0 if the free list is empty.

static void * & nextof(void * const ptr);

This is a convenience function. It helps clean up code dealing with the free list by making it more readable. The return value is just *ptr cast to the appropriate type. ptr must not be 0.

As an example, let us assume that we want to truncate the free list after the first chunk. That is, we want to set *first to 0; this will result in a free list with only one entry. The normal way to do this is to first cast first to a pointer to a pointer to void, and then dereference and assign (*static_cast<void **>(first) = 0;). This can be done more easily through the use of this convenience function (nextof(first) = 0;).

void * find_prev(void * ptr);

Traverses the free list referred to by first, and returns the pointer previous to where ptr would go if it was in the free list. Returns 0 if ptr would go at the beginning of the free list (i.e., before first).

Note that this function finds the location previous to where ptr would go if it was in the free list. It does not find the entry in the free list before ptr (unless ptr is already in the free list). Specifically, find_prev(0) will return 0, not the last entry in the free list.

Interface Description

Valid HTML 4.01 Transitional

Revised 05 December, 2006

Copyright © 2000, 2001 Stephen Cleary (scleary AT jerviswebb DOT com)

Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at