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 is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext

Chapter 8. Boost.Container

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

Introduction
Building Boost.Container
Tested compilers
Main features
Efficient insertion
Containers of Incomplete Types
SCARY iterators
Other features
Boost.Container and C++ exceptions
Non-standard containers
stable_vector
flat_(multi)map/set associative containers
devector
slist
static_vector
small_vector
Extended functionality: Basic extensions
Default initialization for vector-like containers
Ordered range insertion for associative containers (ordered_unique_range, ordered_range)
Constant-time range splice for (s)list
Extended functionality: Configurable containers
Configurable tree-based associative ordered containers
Configurable vector
Configurable static vector
Configurable small vector
Configurable deques
Configurable devector
Extended functionality: Extended allocators
C++11/C++14/C++17 Conformance
Move and Emplace
Stateful allocators
Scoped allocators
Insertion hints in associative containers and preserving insertion ordering for elements with equivalent keys
Initializer lists
Null Forward Iterators
Polymorphic Memory Resources
forward_list<T>
vector vs. std::vector exception guarantees
Parameter taken by const reference that can be changed
vector<bool> specialization
Non-standard value initialization using std::memset
Known Issues
Move emulation limitations in C++03 compilers
History and reasons to use Boost.Container
Boost.Container history
Why Boost.Container?
Indexes
Class Index
Typedef Index
Function Index
Boost.Container Header Reference
Header <boost/container/adaptive_pool.hpp>
Header <boost/container/allocator.hpp>
Header <boost/container/allocator_traits.hpp>
Header <boost/container/container_fwd.hpp>
Header <boost/container/deque.hpp>
Header <boost/container/pmr/deque.hpp>
Header <boost/container/devector.hpp>
Header <boost/container/pmr/devector.hpp>
Header <boost/container/flat_map.hpp>
Header <boost/container/pmr/flat_map.hpp>
Header <boost/container/flat_set.hpp>
Header <boost/container/pmr/flat_set.hpp>
Header <boost/container/list.hpp>
Header <boost/container/pmr/list.hpp>
Header <boost/container/map.hpp>
Header <boost/container/pmr/map.hpp>
Header <boost/container/new_allocator.hpp>
Header <boost/container/node_allocator.hpp>
Header <boost/container/node_handle.hpp>
Header <boost/container/options.hpp>
Header <boost/container/pmr/global_resource.hpp>
Header <boost/container/pmr/memory_resource.hpp>
Header <boost/container/pmr/monotonic_buffer_resource.hpp>
Header <boost/container/pmr/polymorphic_allocator.hpp>
Header <boost/container/pmr/pool_options.hpp>
Header <boost/container/pmr/resource_adaptor.hpp>
Header <boost/container/pmr/synchronized_pool_resource.hpp>
Header <boost/container/pmr/unsynchronized_pool_resource.hpp>
Header <boost/container/scoped_allocator.hpp>
Header <boost/container/scoped_allocator_fwd.hpp>
Header <boost/container/pmr/set.hpp>
Header <boost/container/set.hpp>
Header <boost/container/pmr/slist.hpp>
Header <boost/container/slist.hpp>
Header <boost/container/pmr/small_vector.hpp>
Header <boost/container/small_vector.hpp>
Header <boost/container/pmr/stable_vector.hpp>
Header <boost/container/stable_vector.hpp>
Header <boost/container/static_vector.hpp>
Header <boost/container/pmr/string.hpp>
Header <boost/container/string.hpp>
Header <boost/container/throw_exception.hpp>
Header <boost/container/uses_allocator.hpp>
Header <boost/container/uses_allocator_fwd.hpp>
Header <boost/container/pmr/vector.hpp>
Header <boost/container/vector.hpp>
Acknowledgements, notes and links
Release Notes
Boost 1.85 Release
Boost 1.83 Release
Boost 1.82 Release
Boost 1.81 Release
Boost 1.80 Release
Boost 1.79 Release
Boost 1.78 Release
Boost 1.77 Release
Boost 1.76 Release
Boost 1.75 Release
Boost 1.74 Release
Boost 1.72 Release
Boost 1.71 Release
Boost 1.70 Release
Boost 1.69 Release
Boost 1.68 Release
Boost 1.67 Release
Boost 1.66 Release
Boost 1.65 Release
Boost 1.64 Release
Boost 1.63 Release
Boost 1.62 Release
Boost 1.61 Release
Boost 1.60 Release
Boost 1.59 Release
Boost 1.58 Release
Boost 1.57 Release
Boost 1.56 Release
Boost 1.55 Release
Boost 1.54 Release
Boost 1.53 Release
Boost 1.52 Release
Boost 1.51 Release
Boost 1.50 Release
Boost 1.49 Release
Boost 1.48 Release

Boost.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?

  • Emplacement and move semantics are implemented, including emulation for pre-C++11 compilers.
  • Polymorphic allocators and memory resources, including implementation and emulation for pre-C++17 compilers
  • New advanced features (e.g. recursive containers) and configurability options container.configurable_containers for containers.
  • Containers support stateful allocators and are compatible with Boost.Interprocess (they can be safely placed in shared memory).
  • Users obtain a more uniform performance across all plataforms, including SCARY iterators.
  • The library offers new useful containers:
    • 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.
    • slist: the classic pre-standard singly linked list implementation offering constant-time size(). Note that C++11 forward_list has no size().

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.

Boost.Container requires a decent C++03 compatibility. Some compilers known to work are:

  • Visual C++ >= 10.0
  • GCC >= 4.8

PrevUpHomeNext