If you often need to get these keys (for example, in a large loop), you might be interested in using boost :: bimap . Otherwise, you can use the Nikola solution correctly.
Sometimes I add keys to another container when adding items to the map. To do this, it is necessary to synchronize the two containers, but if it is sufficiently isolated (in the class), then it is easy to configure.
Klaim source
share