Boost
C++ Libraries
...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
This version of Boost is under active development. You are currently in the develop branch. The current version is 1.91.0.
Copyright © 2009-2026 Ion Gaztanaga
Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Table of Contents
forward_list<T>vector vs. std::vector
exception guaranteesvector<bool> specializationstd::memsetBoost.Container library implements several well-known containers, including STL containers. The aim of the library is to offer advanced features not present in standard containers or to offer the latest standard draft features for compilers that don't comply with the latest C++ standard.
In short, what does Boost.Container offer?
[stable/static/small]_vector, flat_[multi]set/map,
devector or segtor.
flat_map,
flat_set,
flat_multimap
and flat_multiset:
drop-in replacements for standard associative containers but more
memory friendly and with faster searches.
stable_vector:
a std::list and std::vector hybrid container: vector-like random-access
iterators and list-like iterator stability in insertions and erasures.
static_vector:
a vector-like container that internally embeds (statically allocates)
all needed memory up to the maximum capacity. Maximum capacity can't
be increased and it's specified at compile time.
small_vector:
a vector-like container that internally embeds (statically allocates)
a minimum amount of memory, but dynamically allocates elements when
capacity has to be increased. This minimum capacity is specified
at compile time.
devector:
is a hybrid of the standard vector and deque containers. It offers
cheap (amortized constant time) insertion at both the front and back
ends.
segtor: a sequence
container with segmented (block-based) storage like deque but only
growth at the back; constant-time push_back/pop_back, random access.
slist: the classic
pre-standard singly linked list implementation offering constant-time
size().
Note that C++11 forward_list
has no size().
For most functionalities, there is no need to compile Boost.Container, since it's a header-only library, just include your Boost header directory in your compiler include path except if you use:
Those exceptions are are implemented as a separately compiled library, so in those cases you must install binaries in a location that can be found by your linker. If you followed the Boost Getting Started instructions, that's already been done for you.
For the CMake build system, the project (CMakeLists.txt) contains
the BOOST_CONTAINER_HEADER_ONLY option that can be set to ON to build the
library as header-only or OFF to build it as a separately compiled library.
Boost.Container requires a decent C++03 compatibility. Some compilers known to work are: