11.3. Operations on Associative Containers
In addition to the types listed in Table 9.2 (p. 330), the associative containers define the types listed in Table 11.3. These types represent the container’s key and value types.
For the set
types, the key_type
and the value_type
are the same; the values held in a set
are the keys. In a map
, the elements are key–value pairs. That is, each element is a pair
object containing a key and a associated value. Because we cannot change an element’s key, the key part of these pair
s is const
:
set<string>::value_type v1; // v1 is a stringset<string>::key_type ...
Get C++ Primer, Fifth 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.