7.8. Maps and Multimaps
Maps and multimaps are containers that manage key/value pairs as elements. These containers sort their elements automatically, according to a certain sorting criterion that is used for the key. The difference between the two is that multimaps allow duplicates, whereas maps do not (Figure 7.14).
To use a map or a multimap, you must include the header file <map>
:
#include <map>
There, the types are defined as class templates inside namespace std
:
namespace std { template <typename Key, typename T, typename Compare = less<Key>, typename ...
Get C++ Standard Library, The: A Tutorial and Reference, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.