Chapter 5. Unordered Associative Containers

The more laws and order are made prominent,The more thieves and robbers there will be.

The Way of Lao-tzuLAO-TZU

Suppose that you’ve been asked to write the symbol table for a compiler. Whenever the code being compiled defines a new symbol, its name and its associated type information have to be stored in the symbol table. Whenever the code uses a name, the compiler has to find that name in the symbol table and dig out its properties. This is a typical job for an associative container: You have the value of a key, and you need to find the data associated with that key. With the current standard C++ library, you can do this with a map:

typedef std::string name;struct type_data { type_id type; unsigned flags; }; ...

Get The C++ Standard Library Extensions A Tutorial and Reference now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.