Chapter 7. Boost.Container (original) (raw)
Copyright © 2009-2018 Ion Gaztanaga
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 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, includingSCARY iterators.
- The library offers new useful containers:
[flat_map](doxygen/boost%5Fcontainer%5Fheader%5Freference/classboost%5F1%5F1container%5F1%5F1flat%5F%5Fmap.html "Class template flat_map"),[flat_set](doxygen/boost%5Fcontainer%5Fheader%5Freference/classboost%5F1%5F1container%5F1%5F1flat%5F%5Fset.html "Class template flat_set"),[flat_multimap](doxygen/boost%5Fcontainer%5Fheader%5Freference/classboost%5F1%5F1container%5F1%5F1flat%5F%5Fmultimap.html "Class template flat_multimap")and[flat_multiset](doxygen/boost%5Fcontainer%5Fheader%5Freference/classboost%5F1%5F1container%5F1%5F1flat%5F%5Fmultiset.html "Class template flat_multiset"): drop-in replacements for standard associative containers but more memory friendly and with faster searches.[stable_vector](doxygen/boost%5Fcontainer%5Fheader%5Freference/classboost%5F1%5F1container%5F1%5F1stable%5F%5Fvector.html "Class template 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](doxygen/boost%5Fcontainer%5Fheader%5Freference/classboost%5F1%5F1container%5F1%5F1static%5F%5Fvector.html "Class template 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](doxygen/boost%5Fcontainer%5Fheader%5Freference/classboost%5F1%5F1container%5F1%5F1small%5F%5Fvector.html "Class template 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](doxygen/boost%5Fcontainer%5Fheader%5Freference/classboost%5F1%5F1container%5F1%5F1devector.html "Class template 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](doxygen/boost%5Fcontainer%5Fheader%5Freference/classboost%5F1%5F1container%5F1%5F1slist.html "Class template slist"): the classic pre-standard singly linked list implementation offering constant-timesize(). Note that C++11forward_listhas nosize().
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:
- Extended Allocators
- Some Polymorphic Memory Resources classes.
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