O'Reilly logo

Boost C++ Application Development Cookbook by Antony Polukhin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using flat associative containers

After reading the previous recipe, some of the readers may start using fast pool allocators everywhere; especially, for std::set and std::map. Well, I'm not going to stop you from doing that, but let's at least take a look at an alternative: flat associative containers. These containers are implemented on top of the traditional vector container and store the values ordered.

Getting ready

Basic knowledge of STL associative containers is required.

How to do it...

The flat containers are part of the Boost.Container library. We already saw how to use some of its containers in the previous recipes. In this recipe we'll be using a flat_set associative container:

  1. We'll need to include only a single header file:
    #include <boost/container/flat_set.hpp> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required