Bogdan Balan Bogdan Balan -4 years ago 202
C++ Question

Iterate keys in a C++ map

Is there a way to iterate over the keys, not the pairs of a C++ map?

Answer Source

If you really need to hide the value that the "real" iterator returns (for example because you want to use your key-iterator with standard algorithms, so that they operate on the keys instead of the pairs), then take a look at Boost's transform_iterator.

[Tip: when looking at Boost documentation for a new class, read the "examples" at the end first. You then have a sporting chance of figuring out what on earth the rest of it is talking about :-)]

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download